jjjw
September 17, 2024, 4:42am
1
I have an array returning photos…sometimes it returns 2, sometimes 3 or 4 items. I want to grab the last item. The make.com instructions are very unclear about how to use the Last() array thing.
My array looks like:
This hard coded one works fine:
But when I try to incorporate LAST, none of these logical options work:
How do I format this correctly to use LAST?! thank you
1 Like
samliew
September 17, 2024, 4:48am
2
You’ll have to use the map function to get the file_id first, then you can use the last function.
This is covered in the Make Academy .
Here are some useful links and guides you can use to learn more on how to use the Make platform, apps, and app modules. I found these useful when I was learning Make, and hope they might benefit you too —
Getting Started
Help Centre Basics
Articles & Videos
Hope this helps! Let me know if there are any further questions or issues.
— @samliew
P.S.: Investing some effort into the Make Academy will save you lots of time and frustration using Make.
Hi @jjjw
applying map() and last() function like this will give you the last file id in the array:
{{last(map(1.photo; “file_id”))}}
Sample structure created:
Output:
Best regards,
Msquare Automation
Gold Partner of Make
@Msquare_Automation
jjjw
September 17, 2024, 6:29pm
4
thanks, getting closer! How can I use that inline? This continues to throw an error:
Perhaps you need to parse the JSON before mapping? What module is this?
Hi @jjjw
Try the following:
{
"file_id": {{last(map(6.Edited Message: Photo[]; file_id))}}
}
Best regards,
Msquare Automation
Gold Partner of Make
@Msquare_Automation
jjjw
September 18, 2024, 10:10pm
7
It’s the “request content” field of the HTTP ‘make a request’ module
jjjw
September 18, 2024, 10:20pm
8
Got it working, somehow in my confusion I was using “edited message” instead of just “message”.
Here’s the syntax that worked in the end – thanks everyone!!
2 Likes