0

I am developing a form in InfoPath to publish to Sharepoint 2010 that will have to do some calculations based on inputs. I am trying to set the value of one field based on the input from 2 option button fields. The problem is there are too many conditions too accomplish this with rules. How can I achieve this with code (C#/VB) in InfoPath Designer?

    If [Field1] = 1 AND [Field2] <4 1 THEN [ResultField] = 30
    ELSE IF [Field1] = 1 AND [Field2] = 4 THEN [ResultField] = 20
        ELSE IF [Field1] = 1 AND [Field2] = 5 THEN [ResultField] = 70
            ELSE IF [Field1] = 2 AND [Field2] <4 THEN [ResultField] = 25
                ELSE IF [Field1] = 2 AND [Field2] = 4 THEN [ResultField] = 15
                    ELSE IF [Field1] = 2 AND [Field2] = 5 THEN [ResultField] = 60
                        ELSE IF [Field1] = 3 AND [Field2] <4 THEN [ResultField] = 25
                            ELSE IF [Field1] = 3 AND [Field2] = 4 THEN [ResultField] = 15
                                ELSE IF [Field1] = 3 AND [Field2] = 5 THEN [ResultField] = 60
                                    ELSE IF [Field1] = 4 AND [Field2] <4 THEN [ResultField] = 20
                                        ELSE IF [Field1] = 4 AND [Field2] = 4 THEN [ResultField] = 10
                                            ELSE IF [Field1] = 4 AND [Field2] = 5 THEN [ResultField] = 50
                                                ELSE IF [Field1] = 5 AND [Field2] <4 THEN [ResultField] = 15
                                                    ELSE IF [Field1] = 5 AND [Field2] = 4 THEN [ResultField] = 10
                                                        ELSE IF [Field1] = 5 AND [Field2] = 5 THEN [ResultField] = 50;

I found this answer InfoPath Calculated Value

which is close to what I think I need.

  • I think calculated field is your best bet, as long as there is a function you have in mind to get the result values. – Ramana Viswanadha Apr 26 '16 at 19:32
0

InfoPath rules don't do the "Else" part. Create a rule for each outcome and place them on the button or the field change event.

If you are hitting the limit of what InfoPath supports, then you may consider changing your technique altogether. Create a SharePoint list with three fields, i.e. Field1, Field2 and ResultField or use an XML file with that structure. Create items in that list/XML file according to the rules above.

In InfoPath, create a data connection to that list/XML file. After Field1 and Field2 are populated in the form, put these into the query fields of the data connection, query the data connection and then use the ResultField that is returned.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.