Code novice here! I am trying to pass the OpportunityContactRole's Opportunity ID from a trigger to a class to a Flow. I would happily use a Process Builder to trigger the Flow but OCR's are yet to run by a PB.
The trigger will run whenever an OCR is added or edited. It should pass the OCR's Opportunity Id to the Class which should in turn pass the OCR's OpportunityId to a flow.
As you can see below, I haven't got very far, but here's what I have pieced together by reading other posts and code
Trigger:
Trigger Default on OpportunityContactRole after insert, after update){
AddPrimaryContactToOpportunity.runFlow();
}
Class:
public class AddPrimaryContactToOpportunity {
public static void runFlow() {
OpportunityContactRole currentRecord;
public OpportunityContactRole getcurrentRecord(){
return currentRecord;
}
Flow.Interview flow = new Flow.Interview.Update_Primary_Contact_lookup(new map<String,Object>
{'recordId' => currentRecord.OpportunityId});
flow.start();
}
Appreciate any help here!
Edit - trigger syntax
Account
object. However, you're trying to get anOpportunity
orOpportunityContactRole
Id. Can you clarify a little bit or maybe you have to edit your code snippets – Bryan Anderson Nov 20 '19 at 18:44