Ordering and controlling structure of Xero Quote Line Items

I am generating a Xero Quote from line items in Smartsuite.

I’ve got an Iterator that iterates over a list of Line Items, which I then aggregate with the Array Aggregator before passing that to the Xero Quote module.

Things I’m struggling with:

  • Ordering - I’ve got access to 2 different order numbers on the line items. How do I use that to sort the Array before passing it to Xero? The stage order and the line item order in the stage.
  • Format - I would like to set up the line items in the following way, but can’t see a way of doing that with the Array Aggregator - any other options to structure the line items. The challenge is that not all the line items will be structured in the same way.
    The high level structure is as follows.
    Projects > which contain stages > each stage contains project tasks.
    For the line items, I am trying to structure it in the following way, before passing to Xero:
    Stage 1 - stage total $
    S1 - Line item 1
    S1 - Line item 2
    etc.
    Stage 2 - stage total $
    S2 - Line item 1
    S2 - Line item 2
    etc.

My Array aggregator at the moment:

Required format:

I suspect some sort of Text Aggregator might be needed here, but ran out of ideas.

Any help pointing me in the roght direction will be much appreciated.

Could you put the words “Stage 1:” in each of the line items that relate to Stage 1 and likewise for Stage 2. Then use a router to craft the projects based on Stage.

Or alternative use tracking categories if they aren’t being used currently and filter by that

I had the Stage on each of the line items, but the client wants it before each stage.

I haven’t used tracking categories before - can you explain more?