01-12-2023 10:18 PM
Identify the record if the entity.success = false then get the one last before record.
For example: if we have 50 records and the last record we got as false, so i want the 49 record value
What i am trying to do here is if the last record entity.success =false then capture the before record entity.nextpageToken
If entity.success =false
if entity.success=true record looks like below and we would like to get the entity.nextpagetoken
How can we achieve this in Snaplogic?
01-13-2023 02:06 AM
Hi @sravankunadi,
You can try using Group By N Snap with Group Size set to 0 to collect all of the records in an array.
Next, you can use the following expression in a Mapper Snap to get the nextPageToken from the last record where success == true.
$group[$group.findIndex(x => x.entity.success == false) - 1].entity.nextPageToken
.
Let me know if this helps you.
BR,
Aleksandar.
01-13-2023 10:11 AM
Thanks @AleksandarAngelevski for your help. Iam getting the below error
01-16-2023 12:39 AM
Hi @sravankunadi,
This would be a case if there is no response with a entity.success == false.
You can separate the process of getting the index and later you can check if the index != -1.
So, If the index != -1 then you can access the latest response with entity.success == true with $group[index-1]
. And if the index == -1 then you can just use $group.pop()
.
BR,
Aleksandar.
01-13-2023 10:14 PM
I would like to mention one point here. I do not know when i will receive the entity.success == false it could be anywhere between 1 min and 60 min. Once i receive the entity.success==false then i would like to the flow from that nextpageToken and would like to loop untill all the records are fetched