Add New Field To Existing Array

Hi all,

I have multiple arrays from file upload dialogs in Jotforms, and merge these together in Make. Before the merge, I need to add a new field to each array to identify the name of the file upload dialog it came from. Example array is below

Doc Name: XXXX.jpeg
Upload Date: 31/07/24

I need to add a new field called “Type” to this array so the new array will look like the below:
Doc Name: XXXX.jpeg
Upload Date: 31/07/24
Type: Supporting Information Upload Dialog

Would appreciate if someone can shed some light on how to do this in Make please.

Thanks in advance

So what you need to do is after you create your array with the doc name and upload date create a variable that will set your type. After that you then want to use an array aggregator and select doc name, upload date and type.

2 Likes

Thanks - this does work. However, I have 15 upload dialogs, which means 15 arrays, so it would mean a lot of additional modules. Is there no way this can be done with functions/code?

thanks

Sure you can do something like this. Create a new array selecting the type and your two other values needed. The keys won’t be defined anymore but they will always remain the same unless you change them. What do I mean by this if you set the second value as id like I did it will always be id but the key won’t say id. Let me know if this helps.

1 Like

Thanks -

So my array output is:

|1| this is a test type|
|2|www.someurl.com/ID2wqe234
|3|ID1234234234|
|4|DOCNAME.jpg|

In principle this should work however the new array is only outputting 1 bundle, but the original array from the file upload dialog has 2 bundles. Any ideas?

Thanks for your help!

So I think I am being daft and not explaining myself/getting confused.

So the array has multiple collections in it, and I want to add the new type field to each collection in the array. Each collection can then have a different “type”

Sorry!

I understand the best and most simplest solution is above. Using the aggregator however, you don’t want to use more operations and do this.

To help further sending screenshots of your scenario with example json output data and the blue print of your scenario will allow me to help further.

1 Like

Hopefully this helps explain a little better. So you can see the file array, with multiple files as collections. I need to add a new field to each collection as shown in the image “Type” = the new field.

Hope this makes sense?

Truly using an iterator and array aggregator is the easiest and most clear way here.

I see and I agree - however, there’s lots of separate arrays, around 35 so it would mean a lot of modules and operations which I don’t think is feesable.

Why would it be alot of modules? Operations are relative my org using 2 mil a month so using 200 is peanuts. It would only take 3 modules. Iterator on file array, set variable for type you can use switch function here to set your type, aggregator bring everything back together.

if there’s 35 arrays, does that mean I would need 35 sets of the iterator, set variable and aggregator?

No, for your issue all you need is one set. Iterate on file, set type, aggregate.

There’s 35 arrays, with multiple collections within each array.

I need to add a new field called type to each collection as they are all different.

Once the type field has been added and given a value , all the arrays will be merged into a single array as they will end up in the same table in a database, so processed in the same branch that adds it to the database, hence merging.

So with the above, I don’t think one set of modules is going to work.

Thanks for trying to help me :pray:

1 Like