JS Controller
onconfirm : function(component, event) {
var windowHref = window.location.href;
var url = new URL(windowHref);
var recordId = url.searchParams.get("c__recordId");
var recordtype = component.get("v.selectedRecordType");
console.log('recordType : ' + recordtype);
console.log('parameter : ' + recordId);
var action = component.get("c.CreateNewCon");
action.setParams({
"recType" : recordtype
});
action.setCallback(this, function(response) {
var state = response.getState();
if (state === "SUCCESS") {
console.log("This is Success");
// I'd like to move from here to url.
} else {
console.log('This is Error');
}
});
$A.enqueueAction(action);
}
I want to process the following code successfully in apex controller and go to the URL when the status is SUCCESS. What should I do?
Best Answer
You can use any of the following event based on where you want to navigate.
E.g you want to navigate to certain URL then use force:navigateToURL event.
Add gotoURLfunction to your component and Inside if condition use it.
Refer component library for more information - https://developer.salesforce.com/docs/component-library/bundle/force:navigateToURL/documentation