Identify the last of one or more items in a Monday.com Connect boards column selection

Hi,

I have a scenario using the Monday.com module “Create a Subitem” that creates a new subitem on Board B when a selection is made in a Connect Boards column on Board A, using the selection as the parent item for the subitem.

This works fine for the first selection, but on subsequent selections, the Item ID of the first selection is always used, not the most recent selection.

In the attached image the Item ID (where the subitem should be placed under) is defined using {{1.value.linkedPulseIds[5].linkedPulseId}}. In this definition, the 5 causes the fifth selection to be used.

Is there a scripting option here that I could use to cause it to select the last (latest) selection? Something like {{1.value.linkedPulseIds[LAST].linkedPulseId}} (which is not a real thing).

Many thanks.

I had a similar usecase and this is how I solved it.

image

You should be looking for IMTAGGLENGHT. This should be your “last” parameter.

Hey @GregG1,

There is a {{length()}} array formula that you can use inside along with the actual array and that should return the last number in that array.

image

Thank you for this suggestion, @Wemakefuture.

It may be that my circumstance is a little different than yours was, as I have just the one bundle, which has multiple value:linkedPulseIds within it. As a result, when I use IMTAGGLENGTH, I always get “1” which always results in the first of the linkedPulseIds.

Is there a way to configure the Iterator or Array aggregator to count the linkedPulseIds?

Thanks again!

@GregG1

The simplest way to reference the last element of a variable array is to use the reverse() function:

So, something like this:


Jim - The Monday Man (YouTube Channel)
What is Make & How can it help you with monday?
We Create Custom Solutions - Your Make or Ours
Schedule a 1-on-1 Tutorial Session (for monday, Make or Excel)

1 Like

Thanks, @JimTheMondayMan

I was able to use the reverse() function by itself as shown below and the scenario runs fine, providing the last selected linkedPulseId instead of the first. Is this going to be a problem?

Creating the variable:

Using the variable:

Thanks again for all of your help.
-Greg

@GregG1

No, that will not be a problem. I generally prefer being explicit with arrays. Also, in this situation, you don’t need the Set variable module.

The way I would do it would be to use this expression in the Item ID of the monday module:
{{get(map(reverse(1.value.linkedPulseIds); "linkedPulseId"); 1)}}


Jim - The Monday Man (YouTube Channel)
What is Make & How can it help you with monday?
We Create Custom Solutions - Your Make or Ours
Schedule a 1-on-1 Tutorial Session (for monday, Make or Excel)

1 Like

Thanks again, @JimTheMondayMan !
That works great and saves me an operation. Much appreciated!

2 Likes