Execute query for each row in repeating table - InfoPath Dev
in

InfoPath Dev

Execute query for each row in repeating table

Last post 09-14-2012 02:41 PM by jeffkinzer. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 07-27-2012 05:18 AM

    Execute query for each row in repeating table

    I've got a people picker on my form that may have several people added to it.

    When the user submits the form I want to execute a data connection query for each row in that people picker schema, and I want to do it using rules only ... no code.

    Details:

    The purpose of my form is to route a document for approvals and training (which consists of reading the document and acknowledging that you have read it). Upon submission it will create a folder in one of 4 sharepoint document libraries selected from a drop down box and the document is placed in that folder. These libraries have restricted access and have associated Sharepoint groups ("libraryname Read"), and I want to be able to add each person selected in the two people pickers to the library's Read group. I can do this easily with Sharepoint's UserGroup.asmx web service by setting the group name, user name, and user ID and executing the web service. It works fine for a single person selected, but how can I iterate thru each person and execute the data connection?

    Added More Details:

    My data connection is a 'receive' connection so that I can set the queryfields. It is linked to http://<sharepoint site path>/_vti_bin/usergroup.asmx, and is named AddUserToGroup

    My complete rule is:

    set a field's value: AddUserToGroup/groupName = concat(DocLibrary, " Read")  '... specify the sharepoint group name
    set a field's value: AddUserToGroup/userName = Person[position() = 1]/DisplayName
    set a field's value: AddUserToGroup/userLoginName = Person[position() = 1]/AccountId
    Query using a data connection: AddUserToGroup

    So now I just need to figure out how to iterate thru the rule for each person. Any ideas?

    Steve
  • 07-31-2012 12:38 PM In reply to

    Re: Execute query for each row in repeating table

    Without knowing how many people have read this question I don't know whether or not this information is useful to others. Would it be possible to put a view count on the thread like the reply count?

    Anyway, I finally figured out how to execute a rule for each row in a repeating table and thought I'd post the answer in case anyone else is interested.

    I created an integer field idx to use as the position of the repeating row, and to that field I added a rule with the above listed actions to set the values of the web service and execute it. I figured that I'd set the value of idx to 1, use it to get the right set of person values, increment idx and do it again until idx > count(Person). But it was a bit tricky getting the value of idx to re-evaluate each time.

    In the place of "position() = 1" in the rule actions above I used "number(../../my:gpFormVariables/my:idx)". You must use number(), and put the full relative path of idx in it to get it to reevaluate each time. Just choose Person/DisplayName, check Edit XPath, then type "[number(full relative xpath to your index field)]" right after Person and before /.

    set a fields value: groupName       = concat(DocLibrary, " Read")
    set a fields value: userName         = Person[number(../../my:gpFormVariables/my:idx)]/pc:DisplayName
    set a fields value: userLoginName = Person[number(../../my:gpFormVariables/my:idx)]/pc:AccountId
    query using a data connection:        AddUserToGroup

    I added another action to increment idx:

    set a fields value: idx = idx + 1

    and then added a condition to the rule so that it would only execute for the number of rows in the repeating table:

    idx <= count(../../my:gpApprovers/pc:Person)

    Then I added a rule to my 'submit' button:

    set a fields value: idx = 1

    Works like a champ, but is subject to the rule of 16 ... it would not run more than 16 times because of Infopath's built in rule to prevent infinite loops.

    Steve
  • 08-10-2012 01:30 PM In reply to

    Re: Execute query for each row in repeating table

    SteveJones:

    Without knowing how many people have read this question I don't know whether or not this information is useful to others. Would it be possible to put a view count on the thread like the reply count?

     

    I support

    Thanks!

    Pity I missed this thread before

     

    Gennady Vanin (Novosibirsk) --- Геннадий Ванин (Новосибирск)
  • 09-14-2012 02:41 PM In reply to

    Re: Execute query for each row in repeating table

    Really good information, thanks!!
Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.