How to grab the last item of an array?

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 :slight_smile:

1 Like

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

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

It’s the “request content” field of the HTTP ‘make a request’ module

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