1

The requirement is to redirect to home page on saving a new To Do record . I have a lightning component with custom button added to Home page that onclick I am creating a new record using force:createrecord . The functionality is working fine, but on saving the record it is redirecting to created record detail page.Is there any way we can redirect to the source page where the button is clicked?

    <aura:component implements="flexipage:availableForAllPageTypes" access="global" >
   <lightning:button onclick="{!c.createtask}" iconName="utility:task" iconPosition="left" label="New To Do " />&nbsp;&nbsp;
    </aura:component>

({
    createtask : function (component, event, helper) {
    var createRecordEvent = $A.get("e.force:createRecord");
    createRecordEvent.setParams({
        "entityApiName": "Task"
    });
    createRecordEvent.fire();
}
})
  • One way i can think of is to call sever side controller and do your sabe there instead of force:createrecord, on success state call the navigatetosobject/navigatetourl method – Rao Oct 11 '17 at 2:32
  • As per the docs , there is no supported hooks for force:createRecord event with which you can redirect. So i guess you will have to build your custom component for granular control. – StormBr34ker Oct 11 '17 at 9:43

Your Answer

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

Browse other questions tagged or ask your own question.