How to check Collection field items for text?

The following scenario goes into my Freeagent accountancy software, looks for the latest draft invoice and adds a new line item (“invoice item”) to the bottom of it.

However, I only want that to happen if the invoice does not already contain an invoice item matching the same title text.

In Freeagent’s data model, an “invoice” object can contain “Invoice Items”. Example: If I were a tradesperson, Invoice INV316 may comprise invoice items “Sink unblocking”, “Painting bathroom”, “Install of new shower head” etc. But I don’t want to add the planned item via Make if it is already present in the invoice.

Here is how an invoice result looks…

“Invoice Items” is an Array of Collections, each of which has a Description.

In my case, I prefix each Description with a date.

I want a check to be carried out for whether the Description of ANY invoice item contains the text of the new item to be added (eg. “Painting bathroom”) (but not the date). But I don’t know how to do that.

I then imagine adding a Filter between “Get Invoice” and “Add Invoice Item”. “Add Invoice Item” should only happen if none of the Invoice Items collections’ Descriptions contains “Painting bathroom”.

How would you do this?

Fairly sure if revolves around Iterator, or Array aggregator or maps.

It sounds like you might be hard coding the information that goes into “Add item to invoice”. If so, that makes it easier.

  1. Set a variable further up with the data you would have added at the end in Add item to invoice
  2. You probably just wanna use the aggregate text function to bring in all the descriptions into one item.
  3. in the filter between get invoice and add invoice item, use Array operators not text operators to perform the contains check against the variable you are setting in step 1.
1 Like