Solved

Forms with Repeating section and workflow

  • 12 September 2019
  • 12 replies
  • 428 views

Badge +2

New user here searching for some guidance.  I have a form for requesting new part numbers.  In the repeating section of the form, is selections from lists for primary category, secondary category, and tertiary category (3-tiered category) - workflow is based on this to determine if product testing is required.  The description and current part number fields (if exists) and fields for print number, unit of measure etc.

My first issue - In the workflow - when the form is saved, I notify our documentation team that there is a new request. I followed that with a wait for item update - so that when documentation adds the part number, the workfflow would then continue.  Except that because the fields are in a repeating panel, they are no longer connected to my original list which the form is based on.  I'm not sure the best practive or course of action to develop this form - There may be examples on here already, and I apologize for that - but when I don't know what I don't know - I don't even know what to search for exactly.   looking for examples that may help.  I should add that this is a multi-use form.  engineering print number request - in which we can request multiple drawings at once, item master request - for new part numbers as described above, as well as things like requesting new kits (similar to item master) and things like warehouse adds - to add an items use to multiple production lines.  the workflow is relatively simple - but since the fields are in the repeater, they are no longer connected to my list - thus I cannot trigger the workflow from that data, and I can't go look at that data in my list as it doesn't store. looking for guidance, thank you.

 

icon

Best answer by kunalpatel 25 September 2019, 21:41

View original

12 replies

Userlevel 6
Badge +22
Hi,
Create a Multi Lines of Text Column in your list and make sure it is configured as Plain text (Not Rich or Enahanced Rich text).
On you form connect the Repeating section to this column.
In your workflow configure the wait for Item update to look for changes in this column.

I dont fully understand the solution requirements but it seems that you are wanting to reference the repeating section data and this would be one way to do that.
Badge +2

Thanks for the reply Simon.  That's partially what I want to do.  I have an engineering request for where designs would submit for new prints numbers as an example.  They may request 5 new prints at once.  So, I added a repeating section.  I'm looking at Vadim's (spelling?) blog post about how to parse the xml from the repeating section - but I am having all kinds of issues.  for example.  one of his first steps is to use regular expressions to replace " with ' and ≶ with > etc.  to make the XML parsable.  


my regular expression feature doesn't change the variable at all.  I verified I had everything setup the same as his example - I've look at both the prem and o365 versions.  no success.  just struggling in general.  

Userlevel 6
Badge +22
If you're using my method where you connect the repeating section to a Multi lines of text column there shoud be no reason use a regular expression to clean up the XML.
If you give me an example of the xml I can do you a demo workflow that demonstrates how to parse it and create new items.

There are also plenty of posts on this community about parsing XML.
Badge +12

@TroyB .... @SimonMuntz  solution is simple...no parsing is needed

Below are the step by step instructions (I've copied my response on similar repeating section post..link to that post ):


 


Instead of using UDA:


 



  1. Simply create a MLT (with plain text) column in a list. Plain text type is very important since it's going to store XML code of your repeating section

  2. On the form, connect your repeating section to MLT column you've created in step # 1. You can remove this MLT column from your views in the list.

  3. Now, create a workflow and:

    1. Use Query XML and use the MLT column from step # 1 as a XML source

    2. Use collection variable to store all the different values of your controls you've put in repeating section

    3. Use one of the collection for "For Loop" and get the index also

    4. Use collection operation for other collections using index

    5. Now in for loop, you have all the values need for each repeating section row, use workflow to maniputlate as per your requiremnt




Let me know if this works for you.


 


- K

Userlevel 6
Badge +22

@kunalpatel What you have described is Parsing the XML??

Badge +12

@SimonMuntz ....yes, but if we connect the recurring section to MLT list column (with plain text) then we don't need the recurring section UDA. It's easy and more manageable.

Badge +2

This works, but I now need to update the XML back after a field has been updated.


Each row has a different value - but when I try to update the field within my loop and update - it updates all records with the same value.  it's not indexing per line.


 


The scenario:  engineer requests a few new part numbers for a new design.  based on the category of the item, there is a status field for "Standardization" this value needs to be set as Approved, Declined, or N/A - as I loop through the rows of the XML - if the part is a standard part - it goes off for approval.  if it's approved I set a variable to approved. if not then declined, and if it's not a stnadardized part - it's set to N/A.  then just before th end of my loop I update the field, then update the xml column.  the problem is, it's taking the last rows value and updateing all rows with that value.  I'm running a test where 1st item should be approved and second item should be N/A....   getting stuck on that now.


 

Badge +12

@TroyB .....I'm confused here....how you're getting approvals for each repeating section row? Are you creating items in a new child list and then run the approval from the child list? 


 


I think it will be more manageable that way. For each repeating section you create new items in a child list.


 


Since you will be using create item in for loop, you can get the item ID # for that child item and store it in a SLT control of a repeating section. Once you get the approval from child list, you can use query xml to query repeating section in the parent and for that child item ID #, you update the other controls in that row.

Badge +2

I've attached an image of the form's repeating section.  I'll describe the stops of logic below.  First, I connect the repeating section to a Multiline column in the list (table). 


I set that to a variable. query the XML variable and extract the elements to collection variables.  I then do a for each loop on the description - as that field will always have information (my loop count). after my loop object, I go to a parallel action and do the collection objects for each field.  on the drop downs for categories, I have to do a lookup for the text values, as it returns the index value by default. I then do a list lookup to a configuration table matching the minor and subminor categories and extract test requirements and a flag for if its a standard part based on the category.  Keep in mind, we are in the for each loop - so these operations are all for each item request row.  I go to a switch branch - where it looks for a 1 or 0 on the standard part flag.  if it's non-std.  i set a variable for the status text, then call a sub-workflow to send out testing tasks.  If it is standard, then i send a request approval task - based on the answer, it sets that status variable to approved or declined.  and on approved - kicks off the test sub-workflow.  all still in the loop so far.  so now, we are at the end of the switch, where the branches re-join.  I then place an update XML. in there, I'm reading the xml variable assigned in the beginning - which is the variable assigned to the column.  in the update field, I've tried several renditions but my xpath is //item[index of loop]/statusfield  with replace node option, and status variable as value.  I've also tried //repeaterdata/items/item[index]/status ...etc.  and just //status


after that I run a create item, where I write the whole row to a separate list along with the index of the original form list - for future queries and linking to our ERP someday.  currently, I then have a math operation and increment the index variable.  as I've tried using the index var of the loop and creating one manually starting at 1 instead of 0 due to a post i've seen.  at this point, the loop ends, then a task is sent to the documentation team to assign a new part number (assuming it wasn't rejected) or was non-standard.  so we are outside the for each loop - the documentation team assigns a part number, completes their task.  I then query the XML again. this time i only extract the new part number field that was updated, assign those fields out to colelctions, etc. then I run an update multiple items and update my secondary list table of the row data, and add the new information.


at this point the last step is notifying the initiator that the request is complete.


 


I'm trying to follow the logic as if it was a piece of paper filled out, handed off, information added, and handed back.  so far, I can do everything except change the XML in the original list column to reflect the status.  writing the parsed XML data to another list works.  but updating the original XML so when the user opens the form or the documentation team opens the form after VP approval - the status field is not blank but instead reflects the correct status - that's where I am stuck.


 

Badge +12

@TroyB ....use below process to update your XML


 


In Parent List:



  • Make sure you have a SLT control "Child Item ID" (or some other preferred name and it's always disabled (I prefer to use "1<2" in rule to always disable....don't want anyone to make any changes to it)

  • Add another calculated control in repeating section called "calc_repsec_row_count" and use "currentRowNumber" function, you can use your description control for this function
    Query XML to get all the collections (row count, child item id, description, status, etc.)

  • Create a number variable called "num_repsec_rowcount" and set default value as "1"

  • For each "Description" get each values from respective collections using collection operation

  • Add Commit Pending Changes after the parallel branch of collection operations

  • Now use if condition to check if child item id control in rep sec is empty or not? If not then create the child item (this will avoid creating duplicate entries in child list)

  • Get the item ID of the child list and when creating item in child also add a column for Parent List Item ID & Parent's Item URL (if you need, it's convenient to access parent item that way, you can ignore if not needed) in Child List

  • Use update XML to update the node using "num_repsec_rowcount" variable, since you have the row count variable you can use that "Replace node contents"

  • Update current item with the above result XML and commit pending changes

  • Increment "num_repsec_rowcount" by 1


 


In child list:



  • Based on status column value in child list, run your approval workflows

  • Once you get your approval:

    • Query the parent list (below steps will be simillar to parent's query XML)
      get the XML and store all the collections

    • Create a number variable called "num_repsec_rowcount" and set default value as "1"

    • For each "Description" value do the collection operations

    • Compare the current item ID # with the ID # in child item id control in the parent

    • Now use the if condition to check if child item ID is a match or not, if it's the match then use the update XML to update the respective control

    • Since you have the row count variable you can use that "Replace node contents"

    • Use the result XML to update the XML column in parent list

    • Add an increment of 1 to "num_repsec_rowcount"



Badge +2

I did get it working with the following post ... but it did not work the first couple of times through.  must have been a syntax error on my part - but finally got it working.


 


https://community.nintex.com/t5/Community-Blogs/Update-Repeating-section-XML-in-a-Workflow/ba-p/82904 

This solution worked perfectly for me. Thanks!

Reply