• Documentation
  • Workato Blog
  • Product Blog
  • Return to Workato
  • Login
  • Automation Institute
  • Documentation
  • Community Forums
New Topic
Discussions Recipe Building Recipe Building Questions
M

Mark

started a topic over 5 years ago

Get a value from the last item in a list?

I need to cycle through a list to the last item and then use the value from that item later in the recipe. I understand repeating through a list and performing actions at each item, or selected items, but how do I test for the last item in the list?

M

Mark

said over 5 years ago

I think I worked out a way to handle this.


I just ran a nested "for each" repeated step to run through the list but without any actions. Then when I use the pill from the nested repeat step it seems to always get the final list item record. Not very elegant but seems to work, I would be interested if there is a better way.

M

Mark

said over 5 years ago

Ended up doing this:

For each item in Infusionsoft Get payment plan by Invoice ID Pay plans do

104
For each item in Foreach Pay plans Pay plan items do

 

  

105
If Foreach Pay plans.Pay plan items Index+1 equals Foreach Pay plans.Pay plan items Size then do

106
Update bill/invoice header details in Xero

C

Chandra Vippena

said over 5 years ago

I am not sure, I completely understood.

To get the last item of the list or array you can use ".last" method. with the list. 

the last function gives the last item or object if the list contains objects, you can access object values with object['fileld_api_name']

Is this you are looking for.

URL: https://support.workato.com/support/solutions/articles/1000173152-list-of-common-formulas-operators-and-how-to-use-them



Amanda Wong

said over 5 years ago

Hi Mark, instead of using the additional actions to obtain the value, you can make use of formula mode .pluck to do this. 


More about .pluck: http://docs.workato.com/formulas/array-list-formulas.html#pluck

Other useful formula for handling arrays: http://docs.workato.com/formulas/array-list-formulas.html#formulas


Field Mapping and Formula


image




Result


image



Login to post a comment

Still can't find your solution?

Send us a ticket, we will try our best to assist you with your problem

Documentation
Developer's Library
Tutorials
eBooks
Product Hour
Product Blog
Workato Blog
Product updates
Customer Stories
© Workato 2022   Privacy   Terms   +1 (844) 469-6752
  • Documentation
  • Workato Blog
  • Product Blog
  • Solutions
  • Forums
  • Tickets
  • Log in
  • Return to Workato
Topic views count