Question

Looping through line items with unknown/variable number of lines?

  • 18 May 2023
  • 1 reply
  • 115 views

I want to zap messages from Slack into a Google Sheet. I want each paragraph to be a separate line on the sheet, except the first line.

 

So I’m using a formatter step to split into line items using a [:newline:] delimiter, but I’m not quite sure what to do with the looping step.

 

The issue is not knowing how many paragraphs the Slack message will have - I might be misunderstanding how the looping step works, but is it possible to loop through multiple line items when you don’t know how many line items each thing will have?


This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

1 reply

Userlevel 7
Badge +11

Hi @sam-accurx, welcome to the Community! 👋

Yes, it’s definitely possible to loop through varying amounts of line-items using the Create a loop from line-items event. Each time the Zap runs it would take all the line items it’s given and run through any actions in the loop for each item individually. There doesn’t need to be a set number supplied every time.

One thing I do want to also mention is that when testing in the Zap Editor it will only ever run through the first item in the loop, but when the Zap is switched on it would process the actions for each line items separately. So you’d see a new row created in Google Sheets for each paragraph of the Slack messages.

Hope that helps to clarify. If you run into any trouble on that or have further questions just let us know. Always happy to help further!