Salesforce Asked by user85687 on December 24, 2021
I have a Flow wrapped in a simple Lightning Component that I use to override the standard "New" button on accounts. I’m running into a couple of issues with the user experience.
At the end of the Flow, I want the user to be redirected to the record they created (instead of looping back to the beginning of the flow). Or at the very least just close the window.
How do I add an "X" or close button to the pop up window so the user can cancel out at any time?
I know you can use the URL redirect in a custom button, or use visualforce, but this is using the standard button AND no vf.
Here’s my component:
<aura:component implements="lightning:actionOverride,force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global" >
<aura:handler name="init" value="{!this}" action="{!c.init}" />
<div aura:id="editDialog" role="dialog" tabindex="-1" aria-labelledby="header43" class="slds-modal slds-fade-in-open">
<div class="slds-modal__container">
<div class="slds-modal__header">
<h2 class="slds-text-heading--medium">New Record</h2>
</div>
<div class="slds-modal__content slds-p-around--large slds-grid slds-wrap ">
<lightning:flow aura:id="quickCreate" onstatuschange="{!c.handleStatusChange}" />
</div>
</div>
</div>
<div aura:id="overlay" class="slds-backdrop slds-backdrop--open"></div>
</aura:component>
Here’s my controller:
({
init : function(component) {
//Find the component whose aura:id is "quickCreate"
var flow = component.find("quickCreate")
//In that component, start your flow. Reference the flow's API Name
flow.startFlow("Member_Quick_Create");
},
handleStatusChange : function (component, event) {
if(event.getParam("status") === "FINISHED") {
var outputVariables = event.getParam("outputVariables");
var outputVar;
for(var i = 0; i < outputVariables.length; i++) {
outputVar = outputVariables[i];
if(outputVar.name === "redirect") {
var urlEvent = $A.get("e.force:navigateToSObject");
urlEvent.setParams({
"recordId": outputVar.value,
"isredirect": "true"
});
urlEvent.fire();
}
}
}
}
})
Any help would be appreciated!
You can use the event e.force:closeQuickAction
to close the popup.
$A.get("e.force:closeQuickAction").fire();
Also, try if the redirect works after adding the above statement. If not, then might have to use window.location
to force a redirect to the created record.
Answered by Prakhar Saxena on December 24, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP