I'm trying to use MNI to start a process for each element in a list of MyCDT, using "Run one instance for each item in <the list>". When specifying the input parameters to the child process, how do I retrieve the index of the item in the list, so I can pass that single element of the list as a parameter (vs the whole list)? I didn't see any process variable that I could use, is there some function I should use to retrieve the current MNI loop index?
Discussion posts and replies are publicly visible
Hi Brad,
You can use [tp!instanceIndex]
Example:
PV is myList
Input would be myList[tp!instanceIndex]
Interestingly when you call a sub-process as an MNI Appian seems to "know" to pass the relevant item from the array into the sub-process without you having to explicitly reference the item using tp!instanceIndex.
Yes - and (frustratingly) exactly how this works is not very well documented. Out of basic paranoia, I usually manually index the array being passed in anyway - somehow it also "knows" when this is done and passes in the manually-indexed entry, fortunately.
Interesting, I didn't try that - or maybe I did but that was before I fixed my type casting problem, so the error message led me down another path.
Stewart, Not always. Just today I am running into this issue where any time I do a concatenation of a field's value on a record instance from the CDT array, for some reason it uses the entire array!
"Record No. " & pv!cdtarray.record_no stores "Record No. 1, 2" into the output variable assuming the array has just 2 records. When I removed the concatenation, it displayed correctly Record No.1 and Record No.2 in the output. I thought this was bizarre!
And that's exactly why I am here now looking for an alternative. Going to try using instance index.
We are on 18.2.