Send me Make a request query or(and) the high quality screenshot of your pipeline .How many records are you searching btw?
Original Message:
Sent: 09-13-2023 14:27
From: Tim D
Subject: Last iteration of the Search step
well, unfortunately, it seems that it is dependent on the amount of records on the Search step. I was able to use the max|attribute='id' no problem when i tested on a very simple app but when i tried it on an app with larger data, it gave me the same error:
Query step produced too many items too allow inline indexed access. Please use a LOOP construct.
I assume it has something to do with the way results are paginated?
Anyway, just in case you had another thought:
My use case was to do a Search step and for each of those records, I want it to update two fields. For one of those fields, i only wanted it to update when it was the last iteration of the loop.
What I ended up doing is: outside of the for loop, I went with a Make A Request step that queries the table with the same conditions as my Search step and then from a discussion that you were also a part of, i take the highest record id from there (since my table settings is sorted by Record ID - low to high) and then just use look up and update the record.
thank you for your help and insights!
------------------------------
Tim D
Original Message:
Sent: 09-12-2023 21:04
From: Prashant Maheshwari
Subject: Last iteration of the Search step
I went down the jinja lane with chatGPT and learned few interesting things ! We can sort the loop also by a variable. In your case you sort by attribute id(which might be default) and then in loop.last you an access the relevant value as well.
{% for record in a|sort(attribute='mobile') %}{% if loop.last %}{{record.id}}{% endif %}{% endfor %}
------------------------------
Prashant Maheshwari
Original Message:
Sent: 09-12-2023 20:50
From: Prashant Maheshwari
Subject: Last iteration of the Search step
Tim,
Some confusion
------------------------------
Prashant Maheshwari
Original Message:
Sent: 09-12-2023 15:07
From: Tim D
Subject: Last iteration of the Search step
at which step do you do that? i assume you do it outside of the for loop?
I'm gonna try it in when i get back on that task but when i've tried to loop it outside of the for loop, after the Search step, i get an error like this:
Query step produced too many items to allow inline indexed access. Please use a LOOP construct
------------------------------
Tim D
Original Message:
Sent: 09-11-2023 16:37
From: Prashant Maheshwari
Subject: Last iteration of the Search step
This is from one of my working jinja code , I believe loop.last is what you want , you will loop.last==true and then your code
{% for i in range(a.enquiry|int) %}
{
"22": { "value" : "{{loop.index}} of {{a.enquiry|int}}" },
"6": { "value" : "{{a.id}}" }
}
{% if loop.last == false %},{% endif %}
{% endfor %}
------------------------------
Prashant Maheshwari
Original Message:
Sent: 09-10-2023 13:37
From: Tim D
Subject: Last iteration of the Search step
How can i identify that the last iteration of the Search step?
On the last iteration, i would like it to stamp a field but I havent found a way to do this through jinja (at least in the way i want it)
this works in getting me the highest record id (which is my default sort for the table):
{% set highest = a|max(attribute="id") %}
{{highest.id}}
and i can use this in the look up step and find the last iteration of the loop, however, i would like to not have to do this part.
on the for each after the Search step, i am trying this:
{% set highest = a|max(attribute="id") %}
{% if a.id == highest.id %}
{{TRUE}}
{% endif %}
but i just keep getting a TypeError: 'Record' object is not iterable.
does anyone happen to know how to stamp a field in a for each loop only when it is the last iteration of the loop?
Thank you!
------------------------------
Tim D
------------------------------