Expand my Community achievements bar.

Help with converting a collection to an array in Fusion

Avatar

Level 1

Currently, I am getting a problem of referencing a specific element in a collection such as "1163:body.data" ("module-number.body:data") in Fusion.  Therefore, I need to convert a collection to an array so that I can use array functions to get specific elements.

 

Does anyone know how to convert a collection to an array in Fusion?

 

I really appreciate it!

 

Anh Ly-Hang

Vanguard Group

4 Replies

Avatar

Community Advisor

Can you include a screen shot of what your data looks like? I'm a little confused on what you are asking for, but I took my best guess below. If I'm wrong, data screen grabs could be useful to understand.

 

Collections and arrays are two different things. If you're just trying to pick something out of a collection, you don't need to use array tools, you can use the get command, which would look like get({yourCollection};{key}).

 

If you are saying you have an array of collections, and you need to drill down to the collection, you can use the iterator module on the array. If there's only 1 item in the array, you can use the get command also, get({yourArrayOfCollections};1).

Avatar

Level 1

Hi Chris,

 

Thanks very much for your shared expertise!  It will remember how to use it.

 

For this reported issue, I was able to figure out how to get data that I needed from different module, instead of from the collection "1163.body.data" which I tried different approaches before, but I could not get data from it.

 

I really appreciated your input!

 

Anh Ly-Hang

 

Avatar

Level 2

Hi Chris, I find this thread relevant so I am posting this question here. Please help.

 

ElanR1_0-1691163064948.png

I've used the iterator with target id and I've 9 bundles since that module and its good. But I am looking to create a variable for documentName and targetLanguage to be used in subsequent modules. 

 

As you said, I've used

ElanR1_1-1691163274457.png

But I am getting only the first collection repeated as below in all bundles. Please help!

ElanR1_2-1691163379254.png

 

Avatar

Community Advisor

Correct, you're essentially saying with your get statement, "Give me the first item in the Data Collection." If you are feeding Data into an iterator, then use the values coming out of the iterator, so for the document name, you'd map the documentName variable coming off of the iterator.