Home > Forum > Plugins > SDK - Variable item list on the invoices

SDK - Variable item list on the invoices
0

Hi,
I have a process that works with invoices. Each invoice contains a variable number of line items (name, price, VAT, etc.). Using an SDK, I’m retrieving these invoices from an API. Since the number of invoices and the number of line items per invoice can vary, how should I configure the SDK so that each line item is correctly mapped to a item list in the process? Is there a specific mapping method for handling a dynamic number of invoice items?

Thanks!

MVP

Hi,

I don't really understand what you want to achieve.

- You get x invoices , number, vendor, date
- Each invoice has y lines, article, price quantity

Do you have one process with two item list, one for the invoice and one for the invoice lines or do you want to create one workflow instance for each invoice and populate an item list with the invoice lines?

Without knowing the whole use case, I would assume that the later would be better, for any kind of approval workflow or similar.

Even if I'm wrong and you want to populate two item lists in one workflow instance, I don't see the issue. I would:
- Retrieve all invoices
- Foreach invoice
-- Add a row to the first item list
-- Fetch the invoice lines
-- Add rows to the second item list with the invoice lines and add a column to store the the invoice number as a reference.


I created an SDK action some years ago to populate an item list from an XML file. Maybe this could be a good starting point for you.

Code:
https://github.com/Daniel-Krueger/webcon_xmlToItemList/blob/main/CC_XmlToItemList/XMLtoItemList.cs
Blog post
https://daniels-notes.de/posts/2021/custom-action-xml-to-item-list

Best regards,
Daniel