+ Start a Discussion
THBrunoTHBruno 

Use of arrays in Flow

Hi,

 

Does anybody has ever used arrays in Visualflows?

It is not possible via the standard variable options in the flow, but in combination with a visualforce page etc...

 

Anybody knows if this is possible? If so, how to manage this?

 

Thanks!

Ashish_SFDCAshish_SFDC

Hi THBruno, 

 

We need more information on this request, can you brief what is your requirement and what exactly you are looking for.

 

Regards,

Ashish

 

 

THBrunoTHBruno

Let me explain it with an example.

 

Assume I have a flow to enter the information about  vehicles. I have a custom object Vehicle and a custom object Tyre.

My flow is loaded in a Visualforce page, which shows the information that I previously entered on the right side, the flow itself showing on the left side.

 

First screen, I enter the information about the Vehicle, no problem. Inputfields are assigned to variables, variables showing on the right side in my visualforce page.

Next, I would like to enter all the information for each tyre of the vehicle.

We don't know upfront how many tyres each vehicles has (moto, car, truck, etc..). So this needs to be defined dynamically (maybe via a dropdown on the previous screen about the vehicle itself).


I understood we can loop in the Flow, but the problem I have in this case is that when the first tyre is entered, I assign the information of the inputfields to variables and when the next tyre is entered, the information of the first tyre is lost, because it's assignment to the variables is overwritten by the second tyre.

Note that in my specific case, I only create the records of the tyres at the end (when all tyres are entered). I do this because the user could go back in the flow to correct some information, but then the record was already created and this would mess up dataquality from my understanding.

 

So what I would like to achieve is some kind of map or array, where I could enter as many tyres as I want, and then in the end loop over it and create those tyre-records one by one.

In that case, my visualforcepage could also loop over my array and show all the tyres correctly and not only the last entered one.

 

 

Ashish_SFDCAshish_SFDC

Hi THBruno, 

 

Thanks a lot for explaining, 

If i understand correctly

- The type of a vehicle will decide the number of tyres, 

- In the flow - You have to manually create records for Tyre object for each tyre (based on the screen1 value)

The problem you are facing is with the only child record being created and associated with the parent record. 

Where as you want to freeze the Parent record and iterate through the number of child records based on the values in the Parent record field.

Please correct me If i am wrong - i wanted to understand the use case before assuming and suggesting.

 

Regards,

Ashish 

 

THBrunoTHBruno

Thanks for your reply.

 

We could even go beyond that.

The problem in fact is that when using Flow, and I want to show multiple records of an object on a visualforcepage, this would not be possible.

 

Unless I assign my first record to variable Tyre1, my second to variable Tyre2 and so on. But that would mean I need to create "hardcoded" a lot of TyreX variables and maybe not use them.

Ashish_SFDCAshish_SFDC

Hi THBruno, 

 

The only way I can think of is to get the details from the Visualforce page and use the variables and Create Records with an APEX Class. 

The data taken from VF page to be used as parameters to be passed and iterated through the APEX class. 

Otherwise the functionality of flow is not sufficient to achieve our requirement. 

 

Regards,

Ashish