1

I have lightning Component which because of function and page length. I'm not able to use inside a modal. Hence, I am using Lightning Custom Tab to call that Component. However, upon saving/Cancel I want the user to be redirected to Opp Record Detail page which happening with force.navigatetoSobject. However, this tab stay open in the Navigation bar. Is there anyway to remove it from there??? or close the Tab completely?

PS: I have tried worksapceAPI but that only works with Console App. We are not using console app here.

2

Are you trying to make sure that after redirecting to force:navigateToSObject the creation tab or the record creation page will close?

Try @Avijit Chakraborty's Solution above. Use Window.close();after getting the DML result of your record creation

so it would be like:

CONTROLLER:

yourDMLFunction : function(cmp, evt, helper){
   var action = component.get("c.yourInsertMethod");
        action.setCallback(this,function(response){
            var state = response.getState();
            var returnedId = response.getReturnValue();
            if(state == 'SUCCESS'){
               //CLOSE THE TAB AFTER SUCCESS
               window.close();
               //THEN NAVIGATE TO SOBJECT
               helper.yourNavigateTosObjectFunction(cmp, evt, returnedId);
            }else if(state == 'ERROR'){
               alert(state);
            }
        });

        $A.enqueueAction(action);
}

HELPER:

yourNavigateTosObjectFunction : function(cmp, evt, opptyId){

    var navEvt = $A.get("e.force:navigateToSObject");
    navEvt.setParams({
      "recordId": opptyId, //THIS IS WHERE YOUR OPPTY ID GOES
      "slideDevName": "related"
    });
    navEvt.fire();
}
| improve this answer | |

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.