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
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 J.Tarun J.
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 J.Tarun J.
Can you check the value of retValue variable?

put an alert(retValue); at line #4