You need to sign in to do that
Don't have an account?
Ryan Frank
Passing variables from a lightning component down to a flow variable
Hi All -
I've followed these posts:
https://developer.salesforce.com/docs/atlas.en-us.salesforce_vpm_guide.meta/salesforce_vpm_guide/components_using_flow_inputs_set.htm
and
https://developer.salesforce.com/forums/?id=9060G000000MV43QAG
But for some reason I can't get the following variable to show up within my flow that is embedded within the lightning component. Code is pasted below - any help is much appreciated:
I've followed these posts:
https://developer.salesforce.com/docs/atlas.en-us.salesforce_vpm_guide.meta/salesforce_vpm_guide/components_using_flow_inputs_set.htm
and
https://developer.salesforce.com/forums/?id=9060G000000MV43QAG
But for some reason I can't get the following variable to show up within my flow that is embedded within the lightning component. Code is pasted below - any help is much appreciated:
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,lightning:availableForFlowScreens, force:lightningQuickAction" access="global" > <Aura:handler name="init" value="{!this}" action="{!c.beginFlow}"/> <aura:attribute name="accountID" type="Id" default="001W000000eUrAFIA0"/> <aura:attribute name="accountName" type="String" /> <aura:attribute name="numberOfEmployees" type="Decimal" /> <lightning:flow aura:id="businessInformation" > </lightning:flow> </aura:component>
({ beginFlow : function(component,event,hlpr) { var flow = component.find("businessInformation"); var inputVariables = [ { name : "sVarID", type : "SObject", value : { "Id" : component.get("v.accountId") } //value : component.get("v.recordId") }, { name : "varTest", type : "String", value: [ "2016-10-27", "2017-08-01" ] } ]; flow.startFlow("deleteMe"); } })I then have a simple screen on the flow to display the variables:
You were so close to the goal.
flow.startFlow("deleteMe", inputVariables ); // I have just added inputVariables, et voilà! all the rest is perfect.
https://developer.salesforce.com/docs/atlas.en-us.salesforce_vpm_guide.meta/salesforce_vpm_guide/components_using_flow_inputs_set.htm
I imported your exported flow:
The method works.
Alain
All Answers
- First check: does your variable allow input?
- Second problem (perhaps solved, just here with the copy/paste): javascript is case-sensitive but not apex and it is a very common trap for the JS controller compared with the Apex controller.
<aura:attribute name="accountID" type="Id"default="001W000000eUrAFIA0"/>value : { "Id" : component.get("v.accountId") }
... one letter "d" instead of "D" and that could not work for the JS controller only because the Apex controller does not care. This problem gave me a hard time at the beginning because there is no warning at all.
Input—Can be set at the start of the flow using Visualforce controllers, or subflow inputs
https://help.salesforce.com/articleView?id=vpm_designer_resources_variable.htm&type=5
I have validated that both variables in the flow are set to input only:
Secondly, good catch with the case sensitive variable with the AccountID field. I've updated the code to the below, but the variables are still not passing through:
What is interesting is that the varTest variable isn't passing through either: (the image below is the output flow that I'm trying to display in a lightning page).
I'm dumbfounded? Much appreciated for all/any help!
I would like to try a new method to help people reading directly the exported definition of the flow.
The steps are explained here: it is much easier than it may seem.
https://developer.salesforce.com/forums/ForumsMain?id=9060G0000005W9uQAE
I could try this new method if you copy/paste your metadata definition of your flow here.
<?xml version="1.0" encoding="UTF-8"?>
<Flow xmlns="http://soap.sforce.com/2006/04/metadata">
<description>removed html</description>
<interviewLabel>deleteMe {!$Flow.CurrentDateTime}</interviewLabel>
<label>deleteMe</label>
<processType>Flow</processType>
<screens>
<name>Show_Me</name>
<label>Show Me</label>
<locationX>241</locationX>
<locationY>170</locationY>
<allowBack>true</allowBack>
<allowFinish>true</allowFinish>
<allowPause>true</allowPause>
<fields>
<name>Heres</name>
<fieldText>test: {!varTest}
id: {!sVarID.Id}</fieldText>
<fieldType>DisplayText</fieldType>
</fields>
</screens>
<startElementReference>Show_Me</startElementReference>
<variables>
<name>sVarID</name>
<dataType>SObject</dataType>
<isCollection>false</isCollection>
<isInput>true</isInput>
<isOutput>false</isOutput>
<objectType>Account</objectType>
</variables>
<variables>
<name>varTest</name>
<dataType>String</dataType>
<isCollection>false</isCollection>
<isInput>true</isInput>
<isOutput>false</isOutput>
</variables>
</Flow>
You were so close to the goal.
flow.startFlow("deleteMe", inputVariables ); // I have just added inputVariables, et voilà! all the rest is perfect.
https://developer.salesforce.com/docs/atlas.en-us.salesforce_vpm_guide.meta/salesforce_vpm_guide/components_using_flow_inputs_set.htm
I imported your exported flow:
The method works.
Alain
Thank you, thank you, thank you! I'm giving you a really big virtual hug right now! I'm not sure how I missed that, but it is now functional and working as expected! Thank you very much!
Ryan