You need to sign in to do that
Don't have an account?
How to call an overridden custom 'Edit' button (in Customer object )to load a lightning Component?
The current situation is like this:
When i click on the radiobutton it passes the corresponding accountId to the following function.
The code in the setCallback lets me popup the account edit screen successfully. The problem is that the popup loads the default recordtype layout. I am expecting the custom Lightning component to be loaded in the popup ( I could override the editbutton on customer page, but how to mimic this edit button click in code?).
When i click on the radiobutton it passes the corresponding accountId to the following function.
doUpdate: function(component,event){ var action = component.get("c.doUpdate"); action.setParams({req : 'test'}); action.setCallback(this, function(response){ var selectedRows = event.getParam('selectedRow'); var navigateEvent = $A.get("e.force:editRecord"); navigateEvent.setParams({ "recordId": selectedRow[0].Id }); navigateEvent.fire(); }); $A.enqueueAction(action); }
The code in the setCallback lets me popup the account edit screen successfully. The problem is that the popup loads the default recordtype layout. I am expecting the custom Lightning component to be loaded in the popup ( I could override the editbutton on customer page, but how to mimic this edit button click in code?).
var cType ="c:ComponentName";
$A.createComponent(
cType,
{
parentID : parentRecId,
actionName : 'view' // Parameter to pass on component
},
function(newComponent,status){
if (status === "SUCCESS")
{
var content = component.find("div1");
content.set("v.body", newComponent);
}else
{
}
}
);
OR
Note ** -- PAFId will be auraId of Div in your lightning component
$Lightning.use("c:AppName", function() {
$Lightning.createComponent("c:ComponentName",
{
parentID : '{!parentRecID}',
actionName : '{!actionName}' // Parameter to pass on component
},
"PAFId",
function(component) {
console.log('comp invoked');
});
});
All Answers
Follow this trailhead , it will solve your problem
https://trailhead.salesforce.com/en/content/learn/projects/workshop-override-standard-action/override_4
Thankyou for the quick reply, however I know how to override the standard button to load custom lighnting conponent using lighning action. This will work when we directly click on EDIT button. But i have the requirement to do it in code.
The sample code snipet allows me to load standard page only!!! I need this custom lighning component to be loaded.
See the below image which pops the default layout.
When i click on EDIT manually below pops, which is expected:
var cType ="c:ComponentName";
$A.createComponent(
cType,
{
parentID : parentRecId,
actionName : 'view' // Parameter to pass on component
},
function(newComponent,status){
if (status === "SUCCESS")
{
var content = component.find("div1");
content.set("v.body", newComponent);
}else
{
}
}
);
OR
Note ** -- PAFId will be auraId of Div in your lightning component
$Lightning.use("c:AppName", function() {
$Lightning.createComponent("c:ComponentName",
{
parentID : '{!parentRecID}',
actionName : '{!actionName}' // Parameter to pass on component
},
"PAFId",
function(component) {
console.log('comp invoked');
});
});