Trouble using eval() on repeating section - InfoPath Dev
in

InfoPath Dev

Trouble using eval() on repeating section

Last post 02-10-2013 10:01 PM by JoshuaValson. 11 replies.
Page 1 of 1 (12 items)
Sort Posts: Previous Next
  • 09-02-2009 07:34 AM

    • g-man
    • Not Ranked
    • Joined on 08-25-2009
    • Posts 12

    Trouble using eval() on repeating section

    I'm having trouble concatenating text boxes from a repeating section.  I've researched and found others have solved this issue, but I can't get it to work for me.  Here's what I have...

    • rsctAddEmail (repeating section)
      • txtAddEmail (text box)
    • txtEmailCC (text box)

    On txtAddEmail I have the following rule:

    • Condition: None - This rule always applies
    • Action: Set a field's value
    • Field: txtEmailCC
    • Value: eval(eval(.., "concat(my:txtAddEmail, ';')"), "..")

    When I test this, only the last text box value I enter gets added to txtEmailCC.  Any help is greatly appreciated.

  • 09-02-2009 09:06 AM In reply to

    Re: Trouble using eval() on repeating section

    Instead of having this as a rule on your txtAddEmail field, try using the eval function as a default value for your txtEmailCC. If your data structure is like the list you posted (with txtEmailCC at the same level as rsctAddEmail) the default will look like this:

    eval(eval(rsctAddEmail, 'concat(my:txtAddEmail, ";")'), "..")

    Make sure you pick rsctAddEmail from the data tree so it has the correct XPath. I've attached a sample to this post, just right click the link in the post header and save the file locally. Open it in design mode and preview it to test.

    Hilary Stoupa

  • 09-02-2009 09:43 AM In reply to

    • g-man
    • Not Ranked
    • Joined on 08-25-2009
    • Posts 12

    Re: Trouble using eval() on repeating section

    Perfect!  Thanks Hilary, didn't think of putting the formula in the default value.

  • 10-21-2009 07:06 AM In reply to

    Re: Trouble using eval() on repeating section

    Hilary Stoupa:

    Instead of having this as a rule on your txtAddEmail field, try using the eval function as a default value for your txtEmailCC. If your data structure is like the list you posted (with txtEmailCC at the same level as rsctAddEmail) the default will look like this:

    eval(eval(rsctAddEmail, 'concat(my:txtAddEmail, ";")'), "..")

    Make sure you pick rsctAddEmail from the data tree so it has the correct XPath. I've attached a sample to this post, just right click the link in the post header and save the file locally. Open it in design mode and preview it to test.

     

    Hilary,

    I am having I believe to be a related issue.  I have a form with two Multiple Selection Lists, so users can subscribe to distribution lists for alert emails we send out for our product outages - one has a list called Business Units and the other is called Applications.  As the user selects from either list, I want those selections to populate a third field called Lists.  Ideally I would like it to format as list.

    Business Units xPath is /my:myFields/my:BusinessUnits/my:BU
    Applications xPath is /my:myFields/my:Applications/my:Apps
    Lists xPath is /my:myFields/my:Lists

    I've tried a version of what you've suggested here, but as I select items, it doesn't populate the field until I uncheck one of the boxes.  Plus it creates a long delimited string. 

    I know the selected items are written to table to hold in the Multiple Selection List field until it is submitted, is there a way I can display a formatted version of those values?

    Thanks in advance!

  • 10-21-2009 10:55 AM In reply to

    Re: Trouble using eval() on repeating section

    Is there a particular reason you want to copy the values from Business Units and Apps into another field? It sounds like you want to copy them into a repeating field -- is that what you mean by formatting the field as a list? If you want to add and populate a repeating field, you'll need to use code or an alternative like qRules.

    However, if all you want is a list control that shows the values in each field, you can do that by adding two bulleted list controls (for example) bound to the Business Units and Applications fields. I've attached a simple sample -- just right click on the link in the message header and save the form locally. Right click the saved file and select Design to open the template in design mode and preveiw. Hope that helps!

    Hilary Stoupa

  • 10-21-2009 11:16 AM In reply to

    Re: Trouble using eval() on repeating section

    I'm so grateful that I have temporary access to your brain...that was too darn easy!  That is perfect!

    Thanks so much!

    Hank

  • 10-21-2009 11:30 AM In reply to

    Re: Trouble using eval() on repeating section

    Wonderful, glad it was what you were looking for!

    Hilary Stoupa

  • 12-22-2009 10:55 AM In reply to

    Re: Trouble using eval() on repeating section

     

    If the items are on a multiple selection list box, can I use this solution to concatenate only the checked (selected) values?

     

  • 04-21-2010 06:59 AM In reply to

    Re: Trouble using eval() on repeating section

    Hi,

     

    I have a related problem using InfoPath 2007:

    My Schema is

    • MachineList (Group)
    • AllOk  (Text)
    • Machine (Repeating Group)
      • Name (text)
      • MachineOk (boolean checkbox - checked = 1) 

    The object is to show in AllOk "OK" when all the records in Machine have the checkboxes checked, and "FAILED" when one or more checkboxes are not checked.

    I can't find the coding to get such a formula running.

    Any hits on how to dow this?

     

     

     

     

  • 04-21-2010 07:21 AM In reply to

    Re: Trouble using eval() on repeating section

  • 04-21-2010 07:32 AM In reply to

    Re: Trouble using eval() on repeating section

     Use this formula as the default value for your AllOk field:

    substring("FAILEDOK", not(/my:myFields/my:MachineList/my:Machine[my:MachineOk != 1]) * 6 + 1, 6)

    You might need to change the path if it doesn't quite match what's in your data source.

    What this does is evaluate to a different part of the string "FAILEDOK" depending on whether there is a MachineOk checkbox that is unchecked.  If there is one, then not(/my:myFields/my:MachineList/my:Machine[my:MachineOk != 1]) will evaluate to false (0), and what you will have is:

    substring("FAILEDOK", 0 * 6 + 1, 6) -> substring("FAILEDOK", 1, 6) -> FAILED

     If all of the MachineOk boxes are checked, then not(/my:myFields/my:MachineList/my:Machine[my:MachineOk != 1]) will evaluate to true (1) and you will have

    substring("FAILEDOK", 1 * 6 + 1, 6) -> substring("FAILEDOK", 7, 6) -> OK

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 02-10-2013 10:01 PM In reply to

    Re: Trouble using eval() on repeating section

    Hi All,

    I am new to SharePoint. And am using the double eval to bind values to a multi select listbox from items of an external list which is filtered based on some fields on the form. I prefer codeless programming ( i mean use rules / xpath functions). I am getting the values in the listbox as a single item checked. i wanted it to be different items.

    Please advise on this matter. Thanks in advance.

    Joshua Ninan Valson
Page 1 of 1 (12 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.