0

I am trying to create a quick Action that calls the flow and lightning component to create a record as suggested in the blog here. I need to create a record of custom object from Opportunity record , using the Quick action as suggested in the blog. I created a flow like below with the Action which calls the lightning component createAXProjectRecords enter image description here

And the Lightning component is like

createAXProjectRecords.cmp

<aura:component implements="lightning:availableForFlowActions">
  <aura:attribute name="InputContactID" type="String" />
  <aura:attribute name="InputAccountID" type="String" />
</aura:component>

createAXProjectRecords.design

<design:component>
  <design:attribute name="InputContactID" />
  <design:attribute name="InputAccountID" />
</design:component>

createAXProjectRecordsController.js

({
 invoke : function(component, event, helper){
   var ContactID = component.get("v.InputContactID"); 
   var AccountID = component.get("v.InputAccountID"); 

   var createRecordEvent = $A.get("e.force:createRecord");

   createRecordEvent.setParams({ 
     "entityApiName": "AX_Project__c", 
     "defaultFieldValues": {
      'Contact__c' : ContactID,
       'Account__c': AccountID

    } 
  });
  createRecordEvent.fire(); 
 }
})

When I try to click on the Quick Action on the Opportunity record I get enter image description here I tried running the flow to debug but it is also throwing Unhandled fault exception. Can anyone suggest me what I am missing here. Error in the flow

enter image description here

0

You might want to change the line where you are entering into createRecordEvent.setParam as follows. While you are at it also make sure that the Account__c and Contact__c (which I hope are look-ups in your case have appropriate FLS settings as well and the name, case is right. That should do the trick.

if(AccountID !="" && AccountID !=null && AccountID != undefined) // Check for ContactID also I am skipping it :-) { createRecordEvent.setParams({ "entityApiName": "AX_Project__c", "defaultFieldValues": { 'Account__c': AccountID } }); } else { createRecordEvent.setParams({ "entityApiName": "AX_Project__c" }); }

| improve this answer | |
  • The record has both the Account and Contact ID's . The flow failed shows the below error – user8801647 Jan 8 at 13:39
  • Added the screenshot the error in the question – user8801647 Jan 8 at 13:40
  • Ok so this confirms the suspicion that the value set at record level is not getting passed from flow to component. Take out param in flow and then hard code the default values and check for the record creation in component and if that succeeds debug the flow output params... – Mitesh Jan 9 at 4:17
  • Good point, you could add a debug screen at the start of your flow to make sure your recordId variable is being populated correctly. And another right before your local action to ensure everything else you're passing into the action has the value you expect. – Salesforce Wizard Jan 10 at 18:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.