Activity Forums Salesforce® Discussions How to override the redirect on saving force:createRecord in Salesforce Lightning?

  • How to override the redirect on saving force:createRecord in Salesforce Lightning?

    Posted by Laveena on September 6, 2019 at 6:03 am

    I need to override the redirect on save of a force:createRecord lightning component.

    var eve = $A.get("e.force:createRecord");
    eve.setParams({
    "entityApiName": "Opportunity",
    "defaultFieldValues": {
    "AccountId" : accountId
    },
    "panelOnDestroyCallback": function(event) {
    console.log('test');
    //console.log(event.getParam("id"));
    var urlEvent = $A.get("e.force:navigateToURL");
    urlEvent.setParams({
    "url": "<some visualforce page url>",
    "isredirect": "true"
    });
    urlEvent.fire();
    }
    });
    eve.fire();

    Nikita replied 5 years, 3 months ago 2 Members · 1 Reply
  • 1 Reply
  • Nikita

    Member
    September 6, 2019 at 6:15 am

    Hi Laveena,

    Firing the force:createRecord event tells the app to use the standard create record page. You can’t catch errors that occur there, or alter the create page interface or behavior, for example, to show an improved error message. For this reason, it’s essential to perform access checks in your own code, before firing the event.

    You can’t prepopulate system-maintained fields, such as Id or record modification time stamps. Default values for these fields are silently ignored.

    So, You can't override the behaviour. You can build your own form and control the behaviour.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos