You need to sign in to do that
Don't have an account?
Martha_Seneta
How to pass collection from flow to Apex?
Within a flow, I'm trying to pass a collection variable as input to an Apex element. However, when I configure the Apex element, the collection variable does not show up as a selectable value in the Source dropdown. In fact, there is not even a section within the dropdown for Collection Variables. Anyone know why?
Here are some relevant details:
Here are some relevant details:
- The @InvocableMethod method that's being invoked accepts a list of Strings as its parameter (even though the name of the param is 'idList').
- In the flow, record lookups populate various variables with record Id values. A collection variable has been declared with Data Type = Text and Input/Output Type = Input Only. An assignment variable is used to add the values of a couple of the Id variables into the collection variable.
- I have double-checked by searching for the collection variable by name within the Inputs dropdown, and have confirmed it is not found.
Source Link (https://developer.salesforce.com/docs/atlas.en-us.salesforce_vpm_guide.meta/salesforce_vpm_guide/vpm_designer_elements_apex.htm" target="_blank" target="_blank)
A solution to this could be to addup the ids/values into a comma seperated string using loop n assignment, then pass this string to the invocable apex method and use the native split method to create a new list.
Though its being quite sometime since you posted your question but I just wanted to reply so that it might help someone ending up on this page.
Update: Collection variable are supported with apex invocable methods.
Use something this
@InvocableMethod
public static List<String>SampleMethod (List<List<Contact>> inputList){
}
or
@InvocableMethod
public static List<String>SampleMethod (List<List<String>> inputList){
}
Sobject collection variable or the collection variables will be available then.
How do i handle the list of strings thats coming from the flow?? Could you please share a sample code if you have any
any quick help is much appreciated.
Thanks
@Mohan,
Have a look at my answer above on May 16,2016.
Or another sample ( reference link : http://releasenotes.docs.salesforce.com/en-us/spring15/release-notes/rn_forcecom_flow_apex.htm)
Does this help ?Can you help with question on https://developer.salesforce.com/forums?communityId=09aF00000004HMGIA2#!/feedtype=SINGLE_QUESTION_DETAIL&dc=Apex_Code_Development&criteria=OPENQUESTIONS&id=9060G0000005nrjQAA
Thanks
athi