Foreach / Loop Through Ticket Numbers in Email Body

Does anyone have a solution for this?

I would like Email2AT (for both incoming and outgoing emails) to update all Autotask tickets referenced in the email body. Instead of stopping at the first ticket number, it should extract all matching ticket numbers, ignore duplicate matches, and create one ticket note on each unique ticket.

Thanks,
Rui

Hi @rui.gomes !

Yes, this can be done using the Iterate action with Return all matches enabled. I recorded a walkthrough showing how to build it.

The basic workflow is:

  1. Add a Perform a Regular Expression Match action against email.body.
  2. Enable Return all matches and store the results in custom.matches.
  3. Add Iterate through multiple items in an array, using custom.matches as the field to iterate and custom.match as the value variable.
  4. Inside the iteration, add Update Existing Autotask Ticket.
  5. Use {{custom.match.TicketNumber}} as the field to search for the ticket number, then configure the ticket note normally.

I initially demonstrated this using separate Autotask API actions to query the ticket and create the note, but the cleaner solution is to put the standard Update Existing Autotask Ticket action directly inside the iteration.

This allows a single incoming or outgoing email to update every Autotask ticket number found in the body rather than stopping after the first one.

Please let me know how this works for you. Additional questions, feedback, and suggestions are always welcome.

Here’s the video: