function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Daniel Glaser 5Daniel Glaser 5 

Problems with create Account from New button on Account List view

Here is what i am trying to do:
1. I setup the New button to call a lightning component using the lightning override. I left Skip record type selection page unchecked.
2. Under Service console i select the new button and the Record type selector appears. The lightning page is setup for a custom create page for one record type, for all others a perform a var urlEvent = $A.get("e.force:navigateToURL"); and set the URL to the account create URL with the record type.
3. For my selected record type the window has a save and cancel. The cancel i use:
            var workspaceAPI = component.find("CreateIDaccount");
            workspaceAPI.getFocusedTabInfo().then(function(response) {
                var focusedTabId = response.tabId;
                console.log('cancelDialog tab '+focusedTabId);
                workspaceAPI.closeTab({tabId: focusedTabId});
            })
This works perfectly in Service Console.
for save I use:
      var workspaceAPI = component.find("CreateIDaccount");
        workspaceAPI.openTab({
            url: '/lightning/r/Account/'+recId+'/view',
            focus: true
        }).then(function(response) {
            workspaceAPI.getTabInfo({
                tabId: response
            }).then(function(tabInfo) {
            console.log("The recordId for this tab is: " + tabInfo.recordId);
            });
And this opens a tab for the new account.

Now the problem,
This does not work for Sales. I had to determine what type of app i am using, either Console or Non-Console. Which I did.
I feel the code i created was a cobb job. The page has to be refreshed in order to have a return page, because if i cancelled the create the page would show a blank area under the account tab. For the recordtype i have the custom page with works fine because i can call the account list view. I have no control when the standard account returns.

3. The final issue, when the Custom Record type screen information is saved I have it return to the Account that was created. 
       var navEvt = $A.get("e.force:navigateToSObject");
        navEvt.setParams({
            "recordId": recId
        });
        navEvt.fire();

This works fine if you are creating a new account from the list view, but when you are trying to create a Contact and on the contact screen you select Create Account, it returns to the new account record. How can i get it to return to the Create Contact screen? 
I did try window.history.back(); but that doesn't work.

 Any suggestion? I can provide if anyone think they can help.
thank you,