How to find if the entity exists in an array or not
Hello,
I have a scenario where i use the Gate Snap and the output of the snap would be a empty array or list of entities in the array as shown below.
If the array is empty, it would give output with "original" values ( i need this to take the values in the forward snaps) and if the array is not empty, it would have the below output.
One of the entity in the array is "Name" and i am trying to use "hasPath" function to check if the array is empty or not but in vain.
Since "Original" values are coming along, even if the array is empty, it is giving 1 as an output if i use the "length" function.
I would like to find a solution to check if the array is empty or not by checking the existence of one of the entities that the array returns.
Thanks
Aravind N
@Charles,
Like Patrick, I was also thinking Velocity (VTL) as a solution, but as I tried to solution your original post, the Workday namespace convention in the property names adds some complexity. I don’t know if Velocity beats the null-safe mapper for your particular use case, but it can be good info for your tool belt in the future.The kind of ugly solution I came up with (in a one-liner) is:
[ { "output" : #set ($pd = $['wd:Project_Data']) #set ($ed = $pd['wd:End_Date']) #if (${ed}) ${ed} #else null #end } ]
I’m not well versed in VTL, so there’s likely something a little cleaner than the above.