Forum Discussion
You can do it in mapper by using this code, which probably can be partially or fully moved in to an expression library function also with some tinkering.
If the document has PickListItems
Then Filter out the element where CustomFieldPickListItemID is = to $Value of the document, returns the first found value of $PickListItems.Value found.
If it does not have PickListItems it returns empty string
$.hasPath("PickListItems") ? ($PickListItems.filter((PickListItem) => PickListItem.CustomFieldPickListItemID== $Value ))[0].Value : ''
- reuben2 years agoNew Contributor
How are $PickListItems and PickListItem defined? Would that need to be done in separate mapper?
if $CustomFields is defined as the array above, I had to use two mappers:
One to get the value and one to get the field itself (item in the custom fields array):
$servicesizefield: jsonPath($, "CustomFields[*]").find(x=>x.FieldName=="ServiceTypeSize") $servicesizevalueid: jsonPath($, "CustomFields[*]").find(x=>x.FieldName=="ServiceTypeSize").Value
then
jsonPath($,"$servicesizefield.PickListItems[*]").find(x=>x.CustomFieldPickListItemID==$servicesizevalueid).Value
to get the actual value at that id.
How would I adapt that to expression library as jsonpath doesn't seem to work at all?