Best answer

Merging data from line items

  • 6 July 2023
  • 2 replies
  • 451 views

Userlevel 1
Badge

I’m working on a project where I use Python code and make requests to an API to get specific data and then turn the output log from the code into line items which all works fine. However, now I’m having issues with trying to merge specific line items together.

 

To create the line items I’m using Formatter by Zapier > Text > Split Text and have my custom separator set + segment index set to “all (as separate fields)”.

 

Values for the line items are as follows:

Item 1 - Person name

Item 2 - Project name

Item 3 - Task name

Item 4 - Hours worked on task

Item 5 - Hourly rate


To visualise the problem with example data:

 

Because all the line items “item 1” are John Doe, I would like to categorise them together to create 1 invoice in Xero and then add to that invoice instead of creating multiple invoices.

icon

Best answer by Niiikow 7 July 2023, 13:37

View original

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

2 replies

Userlevel 7
Badge +14

Hi @Niiikow 

Good question.

If you are already using a Python Code step, then you can use the Code step to handle and manipulate the data.

Try asking ChatGPT for help with the Pyhton code: https://chat.openai.com/

Userlevel 1
Badge

For anyone interested and has a similar problem, I’ve managed to find a way around this.

I had to rework a couple of steps in Zapier. So now the Zap will:

  1. Run Python code that only retrieves the users from the API.
  2. Loop through the users using Looping by Zapier.
  3. Make a new Python code step inside the loop that has rest of the original code which needs slight changing to not include the names anymore, to then print the necessary data for the user (using the loop user name as input data).
  4. Use the Formatter by Zapier > text > split text > segment index (all as separate fields) and select the Python “log” as the input to create inline items for the user. 👍 (This may vary for others, you may return output and have different variables, for me personally Zapier output doesn’t currently allow complex enough dictionaries to be usable in my case)

Hope that this explanation helps anyone who’s having similar issues.