Hi everyone, I'm having this issue where I'm trying to index a date and time array using the index of caseID from another array with same order. Below are the process variables and the code that I wrote:
However there was no updatedDateTime value passed into my sub-process, so I'm wondering what did I do wrong with the indexing.
Any idea? Thanks a lot in advance :)
Discussion posts and replies are publicly visible
With seeing the data its impossible to say anything. I recommend to not "hide" such logic inside the value assignment, but use a separate script task and store the result in a PV. That make debugging also a lot easier.
Are casesWithTasks and allCases same type? Is pv!updatedDateTime an array/dictionary? First i will take your where contains and check it manually if it ever return any true for any tpinstanceinex. Then check if index of pv!updatedDatetime return anything if you provide 1 or 2 as second argument.
I want to find datetime for each casesWithTask then pass that value into my sub-process. Not sure if tp!instanceIndex can be used in scriptask?
Yes. casesWithTasks and allCases are both integer. updatedDateTime is now Date and Time (multiple values) type.
I created a scriptask and tried index(pv!updatedDateTime,wherecontains(pv![a case ID instead of pv!casesWithTask[tp!instanceindex],pv!allCases),null), this will return me the exact date time at that index. But it does not work with tp!instanceIndex not sure why...
I understand. But almost impossible to debug. Maybe you want to create an expression that creates a list of maps containing the required data that you then pass to your sub processes.
The input variable type for sub-process is Date and Time, so when I index from Map, the value cannot be passed into sub-process due to data type mismatch...
how many sub processes are triggered? is number correct? Is casesId passed right to sub process? If yes then there is nothing wrong with tpinstanceInded - there is something wrong with if.
If you need to just pass a single value, then go with this and skip the map. I just wanted to give you an idea of how to approach that situation in a different way.
I second Stefan's suggested approach. Add a single script task node right before your subprocess call, and have it output to a new PV of type Array of Map.
The script task would have a single output entry wherein you reassemble essentially the same code you were trying to pass directly into your subprocess inputs:
a!forEach( pv!casesWithTask, a!map( caseId: fv!item, updatedTime: index( pv!updatedDateTime, whereContains( fv!item, pv!allCases ), now() ) ) )
You would then hopefully have a PV set to the proper value(s) for your input array, which you can verify the correct values of. And then for your subprocess inputs, you'd simply set the MNI to reference your new Map PV, and the inputs would be pv!myNewMap[tp!instanceIndex].caseId, and pv!myNewMap[tp!instanceIndex].updatedTime.
Also (and somewhat confusingly), you might not even need the tp!instanceIndex reference when referring to the specific PV set as the MNI identifier - Appian seems to use some sort of fuzzy logic to automatically pull the "current index" at least when not otherwise overridden. I haven't tested this extensively recently but it seems to somehow work both ways in some instances. If anyone knows in any more detail how this works exactly, I wouldn't mind a better description myself, hah.