1

I'm firing force:createRecord event from custom lightning component in lightning service console and it seems to always open a new tab or subtab with the record creation form in it. Is it possible to choose to open this in the same/origin tab or in a modal. There doesn't seem to be any documentation on this.

1
  • 2
    Generally speaking, if it's not in the docs, it doesn't exist.
    – sfdcfox
    Jan 17, 2019 at 13:34

1 Answer 1

3

I faced a similar issue working in lightning service console. I used workspace api to close the tab before firing the force:createRecord event. This helped me to tackle it. Do check out the code snippet for your reference.

<!--in component-->
<lightning:workspaceAPI aura:id="workspace"/>

//in controller
var workspaceAPI = component.find("workspace");
workspaceAPI.isConsoleNavigation().then(function(response) {
   if(response){
      var focusedTabId = response.tabId;
      workspaceAPI.closeTab({tabId: focusedTabId});
   }
});
var createAcountContactEvent = $A.get("e.force:createRecord");
createAcountContactEvent.setParams({
   "entityApiName": "Account",
   "recordTypeId": component.get("v.TypeOfRecord")
});
createAcountContactEvent.fire();
1
  • 1
    +1. Closing the current tab and allowing e.force:createRecord to open in tab. Awesome. Feb 17, 2019 at 21:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .