I have a DataAction that can return the following result:
{
"entities": [
{
"LongName": "Here is a long name",
"key": "long1",
"Classes": "A,B,C"
},
{
"LongName": "Here is a long name",
"key": "long2",
"Classes": "D,E,F"
}
],
"pageSize": 25,
"pageNumber": 1,
"total": 2,
"pageCount": 1
}
I have a translationMap for the result that looks like this:
{
"translationMap": {
"result": "$.entities[?(@.LongName == 'AMCAP Fund' && @.Classes.indexOf('D') != -1)].key"
},
"translationMapDefaults": {
"result": "[]"
},
"successTemplate": "{"entities.key": ${result}}"
}
With the hope that entities.key will return "long2"
But I keep getting nothing. If I remove the "indexOf" check, it returns the key for the first entry. But I need it to return only the key where the "D" is within the Classes.
Am I using indexOf incorrectly? Or is there another way to accomplish this?
Follow-up question:
If so, is there also a way to do an indexOf a whole word, so that if I had two comma-delimited lists, "A,B,C", and "AA,BB,CC", it would return 0 for the first one, -1 for the second one, if looking for the indexOf 'A'