Appian 25.3
I'm using a!queryRecords(.....).data to get an array of records from my record type in a process model. Next, I setup a loop and need to index each record in the array. However, this syntax does not work within the process model:
pv!myRecords[pv!recordIndex]
I receive this error:
An error occurred while evaluating expression: myRec:pv!myRecords[pv!recordIndex] (Expression evaluation error: PE My RecType must be indexed by its corresponding record type fields or relationships) (Data Outputs)
This exact, same syntax works if I move it into an expression rule and call that from the process model.
The process variable is of the exact same type as the rule input on the expression rule (i.e. array of my record type). Yet, I cannot index the array directly in a script task in the process model
Is there something I'm doing wrong here?
Thank you.
Discussion posts and replies are publicly visible
stevenh6272 said:However, this syntax does not work within the process model:
What do you mean? What do you observe?
Yes, sorry, I forgot to post the error message. I need to regenerate the error and I will post the message in a bit.
Thanks.
is the PV actually set to Array/Multiple type?
I did and received the same error.
Can you share your code snippet here?
Here is the exact line in the script task:
pv!performanceRecords[pv!recordIndex]
Here is the error:
Here is the screen shot of the data type
Here's the exact line using index (without a default)
index(pv!performanceRecords, pv!recordIndex)
Here's the error:
Now, you had mentioned using index with a default of null. When I do this, it assigns null to the output variable (which of course causes downstream failures because a record is expected).
index(pv!performanceRecords, pv!recordIndex, null)
But expression rules can do both of these things without any problem.
What happens if you replace "pv!recordIndex" in your test code here with the literal value of "1"? e.g. index(pv!record, 1, null())
Because I suspect this might be messing you up:
recordIndex is Text, not Integer. Record arrays must be indexed by an integer.Change recordIndex to Number (Integer), or use index(pv!performanceRecords, tointeger(pv!recordIndex), null).
e.g.
Aha! I had not noticed the data type issue. That would explain the matter.
The expression rule does accept an integer and Appian automatically converts the Text string to a number.
Such a simple mistake.... so much time lost.
Thank you!
Ran just fine using the [] indexing with an actual Numeric indexer.
Thanks all.
stevenh6272 said:Such a simple mistake.... so much time lost.
Been there, hah.