How to adjust # of row items depending on # of bundles

I want to create a (Visma eAccounting) Invoice with as many rows as there are articles in a (Pipedrive) Deal.

The only solution I came up with is creating several eAccounting modules, one for each amount of articles/bundles, and filter them.

This is manageable in this scenario, but it won’t hold for scaling… And there must be a smarter way to do this?

Here is the scenario in full, where I just did a test run for a two article deal:

And here is an example from the 3 article module. As you can see I have set up one item per article, mapping the array’s n:th element.

Hello @Peligrandio,

You should be able to remove your router and stick to a single Visma module.
Then, in the Visma module settings, tick ON the Map option next to “Rows”.
This should give you just a single input box instead of allowing you to add/enter one Item at a time.
Then, back in your Array Aggregator, you should be able to select a Visma Data Structure from the dropdown. The dropdown list is populated from structures found in modules that come AFTER the aggregator module, so you’ve got to connect them first before you’ll see the option.

If that doesn’t work, maybe try the same, but with a JSON aggregator instead.

4 Likes

Hi @Donald_Mitchell,

Thank you for your reply.

Great tip with the Data structure. I’d actually already done that - but I which I had asked here first since it took me half a work day to figure that one out. :slight_smile:

I now tried just adding the whole array in the “manual” row map - and it worked (after some tinkering with filling out some additional necessary values).

The problem now is that I had a manually added item last in each of the old Visma modules.

I guess I could use the merge array function somehow, maybe like this?

Screenshot from Brave Browser 2023-10-13 at 18.02.59

:grimacing:

I hope I’ve got this right, maybe something like this…

It looks like the input to the Visma module is an array of arrays - one main array where each element is itself also an array.

If final_array is the array that is created by the aggregator, then you want to add another element (and this element is an array) to that main array.

The way to add an element to an array is by using the add() function. There will be one add() nested within another. This will be the outer add().

The way to build a new array is to use add() and specifying {{emptyarray}} as the array you want to add items to. This will be the inner add():

add({{emptyarray}};Item1;Item2;etc…)

Example of what it might look like:
image

3 Likes

Thank you for providing additional help here.

I tried your solution, but there were two problems. The collections are encased in curly braces, while the add() added an array with square brackets. And there were escape backslashes being added, which I found no way arround.


But i came up with another solution:

  1. Added a Parse Json module inbetween

  1. Snatched the Output from the Array Aggregator and generated a Data Structure from it in the Parse Json module

  2. Made changes to the Output (and limited it to one collection) and put that as the Json string (in other words an identical structure to the one generated by the Array Aggregator.

  1. Merged the Array Aggregated array with the Parse Json array in the Visma module; and voilà! Solved!

:facepunch:t2::grinning::+1:t2:

1 Like

Very nice, glad you got it all sorted out!
Be sure to mark your own answer as the solution :grinning:

2 Likes