0

IE i have a request for a classic to lightning conversion.

There's two buttons that exist that pass parameters to a new record creation page (modal in lightning). One button creates a opp of recordtype x the other of record type y, and they also pass different values over.

I was going to go with a Click the quick action --> component front end shows a picklist of record types, pick one and pass it to a a function that does the e.force:createRecord but with a switch depending on the record type, but they don't want that because...well you know how sales people are. So it had me thinking, i can pass the sObject from a page a quickaction-->cmp is initialized from.....you can in fact pass a lot of information.

But can you pass the name of the quick action that initialized the component to the component? Then do something like this.

showCreateRecordModal : function(component, recordTypeId, entityApiName) {
debugger;
var objectType = component.get("v.quickActionName");
var createRecordEvent = $A.get("e.force:createRecord");
 console.log('QA name is TYPE IS: ' + JSON.stringify(quickActionName));
if(createRecordEvent){ 
    if(recordTypeId){
        //using switch if sobject type needs to be expanded (it's a cleaner way than if/else)
        switch (quickActionName) {
            case "Create_International_Opp":
                    createRecordEvent.setParams({
                        "entityApiName": entityApiName,
                        "recordTypeId": <record type y>,
                        "defaultFieldValues": {

                          data to be passed,
                        }

                    });
                    createRecordEvent.fire();
                    break;
            case "Create_domestic_Opp":
                createRecordEvent.setParams({
                    "entityApiName": entityApiName,
                    "recordTypeId": <record type x>,
                    "defaultFieldValues": {

                        data to be passed,

                    }
                });
                createRecordEvent.fire();
                break;
        }
  • The linked answer should help you. If not, please feel free to let us know, and we'll gladly reopen your question. – sfdcfox Jul 19 '19 at 20:02
  • @sfdcfox there doesn't seem to be a link – ensir Jul 19 '19 at 20:45