How do I get the current row for a repeating section in a NAC start form?
In Nintex for SharePoint on-premise we could use the runtime function of currentRowNumber.
I’ve tried with both a label and a number or text control and set the default value to a function but nothing matches that I can see.
Has anyone else found a solution?
What I’m trying to achieve is a repeating section with a drop down control for a selected activity. The form submitter can choose upto 5 but we would like to preference each row as 1st preference, 2nd preference or Preference 1; Preference 2, etc.
Best answer by bsikes
Here’s what the repeating section looks like:
The approach I went with is basically this:
Use the convertToString function to convert the repeating section to a string.
Use the replace function to remove everything after the current row from that string
Use the replace function to remove everything from that string except a specific character that should only be present in each row once.
Count the resulting string, which should correspond to the current row number.
The trick with step 2 is that you need some way to identify what the current row is amongst the whole repeating section. I found that using the newGuidAsString() function accomplishes this well, in that it creates a unique value in a row, that you can reference from within the CurrentRow context. To do this, I have a form rule that when a new row is added, will set a hidden short-text field using this formula: "UniqueRecord" + newGuidAsString()
I’m then able to use a regular expression to remove everything after the current row, using the value from the current row’s GUIDLabel field to actually identify where that cutoff is. The reason for me putting “UniqueRecord” in the field is for step 3.
In step 3, I remove any character that isn’t followed by “UniqueRecord”, which should give me a string that I can count the length of.
Let me know if there’s any questions on that. It would be handy if there was just a built in variable for the CurrentRow context that could be referenced.
The trick with step 2 is that you need some way to identify what the current row is amongst the whole repeating section. I found that using the newGuidAsString() function accomplishes this well, in that it creates a unique value in a row, that you can reference from within the CurrentRow context. To do this, I have a form rule that when a new row is added, will set a hidden short-text field using this formula: "UniqueRecord" + newGuidAsString()
I’m then able to use a regular expression to remove everything after the current row, using the value from the current row’s GUIDLabel field to actually identify where that cutoff is. The reason for me putting “UniqueRecord” in the field is for step 3.
In step 3, I remove any character that isn’t followed by “UniqueRecord”, which should give me a string that I can count the length of.
Let me know if there’s any questions on that. It would be handy if there was just a built in variable for the CurrentRow context that could be referenced.
Hello @Gavin-Adams, thank you for your feedback and the valuable discussion here. We have now introduced a new current row number variable for repeating sections. The current row number variable is accessible from the the Repeating Sections object variable > Current row > Row number.