+ Start a Discussion
ramesh k 29ramesh k 29 

lighting component cancel button i hit the button it should be redierct to opportunity tab

Hi,
i have lighting component cancel button when i hit the cancel button it should be redierct to opportunity tab 
i wrote a some code it close the window but it not redirect to opp tab pleasee help me some one
this is my page

User-added image
for that i wrote a following code
doCancel: function(component, event) {
        var retValue = component.get('v.OpportunityID');
        if(window.opener == null){
            window.location.href = "/"+retValue;
        }else{
            window.close();
        }
    }
 
Tarun Khatri (TK)Tarun Khatri (TK)
Hello Ramesh,

Lightning won't support Window.location. You can either use navigateToSObject or navigateToURL. For e.g.:
doCancel: function(component, event) {
	var retValue = component.get('v.OpportunityID');			
         // Considering retValue contains Oppty Id
	
        var navEvt = $A.get("e.force:navigateToSObject");
	navEvt.setParams({
	  "recordId": retValue
	});
	navEvt.fire();
}

-Thanks,
TK

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
ramesh k 29ramesh k 29
Hi Tarun,
i am getting following error

Cannot read property 'setParams' of undefined
Tarun Khatri (TK)Tarun Khatri (TK)
Can you check the value of retValue variable?

put an alert(retValue); at line #4