08-05-2024 10:10 PM
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
Solved! Go to Solution.
08-07-2024 04:16 AM
Hello @arvindnsn,
You can filter the array that comes out from the Gate Snap using the following expression:
$input0.filter(x => x.hasPath("Name")).length > 0
Based on the result of this, if no element has Name field it will return false, otherwise it will return true.
Attached below is a sample pipeline that you can review.
Please let me know if this helps you.
Regards,
Aleksandar.
08-07-2024 04:16 AM
Hello @arvindnsn,
You can filter the array that comes out from the Gate Snap using the following expression:
$input0.filter(x => x.hasPath("Name")).length > 0
Based on the result of this, if no element has Name field it will return false, otherwise it will return true.
Attached below is a sample pipeline that you can review.
Please let me know if this helps you.
Regards,
Aleksandar.
08-07-2024 08:28 PM
Hello @Aleksandar_A,
That worked perfectly. Thank you very much!