function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Steve Connelly 5Steve Connelly 5 

How do I pull a case ID into a flow?

I am working in Lightning.

I have created a lightning component to launch a flow from a case. How do I pull the case ID into the flow? Once I get the case that the flow was launched from, i can get everything else I need through the flow.
I am new to all this so basic steps if possible.

My lightning component is writtem in HTML and CSS.

Any help will be greatly appreciated.

Best regards,
Steve
Best Answer chosen by Steve Connelly 5
Ajay K DubediAjay K Dubedi
Hi Steve,

If you are launching flow using Lightning component then you can pass values to the variables in the following way.
var flow = component.find("flowData");
var inputVariables = [
 {
    name : "ClaimIdVar",
    type : "SObject",
    value : { 
           "Id" : component.get("v.recordId"),
           "otherVarFieldName__c" : storeResponse.yourFieldApiName__c
           }
    //value : component.get("v.recordId")
  }
];
// In that component, start your flow. Reference the flow's Unique Name.
flow.startFlow("SubmitToTPA", inputVariables );

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Ajay Dubedi
www.ajaydubedi.com

All Answers

Ajay K DubediAjay K Dubedi
Hi Steve,

If you are launching flow using Lightning component then you can pass values to the variables in the following way.
var flow = component.find("flowData");
var inputVariables = [
 {
    name : "ClaimIdVar",
    type : "SObject",
    value : { 
           "Id" : component.get("v.recordId"),
           "otherVarFieldName__c" : storeResponse.yourFieldApiName__c
           }
    //value : component.get("v.recordId")
  }
];
// In that component, start your flow. Reference the flow's Unique Name.
flow.startFlow("SubmitToTPA", inputVariables );

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Ajay Dubedi
www.ajaydubedi.com
This was selected as the best answer
Steve Connelly 5Steve Connelly 5
Good morning! Thanks for the reply. A couple of questions as I am a nube. Do I use this in the developers console? and if so, is this in the component or the controller?

I ask because when I try to add this to my current controller, i get this error:

Failed to save HDFlowFromCaseController.js: c.HDFlowFromCase: org.auraframework.util.json.JsonStreamReader$JsonStreamParseException: Expected ',' or '}' [36, 1]: 'var': Source

I have fiddled with this but can't seem to get past this. As well, which parts of this do I need to edit for my use? Just the following?
 "otherVarFieldName__c" : storeResponse.yourFieldApiName__c

And if I do not need anything but the case ID can I just remove this part?

Thnks much,
Steve
Naveen KNNaveen KN
If you are working with screen flow and you need case id, then you can just create a variable recordId within the flow and use it across your flow. 

Regards,
Naveen K N