Can you Modify Subform data, not just use it inside a loop?



  • Avatar
    Karl Makatenas

    How are you using the array indexing variable?  I know :[this] won't work because there's no direct reference to the "this" variable outside of the form, so have you tried :[${/pd:AP/pd:processFields/stuff}] or is that not overwriting the data?  I remember this being a chore to figure out the last time I messed with it and never came to a conclusion because we figured out a way to work with the data sans modification.

  • Avatar
    Loren Bratzler

    I have run into this issue as well where I would like to be able to update repeating data in a loop.  In fact, I even created a little test application to try to accomplish this but was never able to get it to work.

    I know that if you go into the Process Monitor / Data tab and look at the XPath for a repeating element, you will see an index in brackets that appears right after the "repeating" node of the path:


    So it stands to reason that you should be able to define an index variable in your processFields that you initialize to zero before starting the loop.  Then within each iteration of the loop, you increment the index variable by 1.  Then you just need to update the current entry with the new value by indexing it with your index variable.  Of course, to do that, you can't just drag-n-drop the field from the schema to the Process Variable field since it won't have any indexing.  So I tried to hard-code the field with index like this:


    But what happens is that it only updates the first entry in the repeating element.  So for example, if you have 3 entries in your sub-form, the first occurrence gets updated with what you intended to update in occurrence 3 while occurrences 2 and 3 do not get updated at all.

    Here is a link to my Test Application:

    Test Update Loop

    If anyone can figure out how to make this work I am sure a lot of people could benefit from it.

    AgilePoint needs to consider creating an activity for doing this or enhancing the "Update Process Data" activity to be able to do some kind of indexing for repeating elements.


  • Avatar
    Karl Makatenas

    So the best alternative I could come up with in a reasonable amount of time is to export all the data to another data source, then read the data back into the repeatable section.

    In my example, I looped through all the data, made modifications to each row while putting the row in SharePoint, and pulled the data back via a CAML query.  It works, but it's obviously not my first choice.

    It seems the issue exists because I can't further nest process variables into the left side of the Update Process Data activity due to the way the C# seems to parse, so I can't save back data to particular array indices.  I can read data from specific array indices, though.

  • Avatar
    Karl Makatenas

    The documentation seems to hint that we can change repeatable data, so now I'm curious about the syntax:

    Process Data Variable

    Accepted Values:
    • An Xpath to an XML schema element.
    • At runtime, if the schema element does not exist, the process ignores the action. If you want to change a repeatable XML element, make sure it exists in the schema. 

  • Avatar

    The subform can be modified by JS as long as it is on the form. (Can stay hidden)

    We are modifying a unique ID, to ensure it is unique before writing it to a SQL database table via Data Population. 

    Edit: Our code was developed jointly with professional services so I do not know if I can/should share it directly here. 

  • Avatar

    Yes, we are modifying repeating data inside a form with JS as well.  The documentation AgilePoint provides is quite good in that regard, albeit that adding extra rows is very slow. 

    I am really wondering how we might be able to do it outside a form, with the Update Process Shape or similar. 

  • Avatar
    Karl Makatenas

    This use case seems to hint that the form is already submitted, so the data has to be edited within the process (outside of the form).  Inside the form is relatively easy with JS.  I still don't have any other options than the SharePoint bulk upload to a CAML query download mentioned above.

Please sign in to leave a comment.