Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var windowHref = window.location.href;
- var sObjectName = "Account";
- var recTypeID = "xxxxxxxxxxxxxx";
- var createRecordEvent = $A.get("e.force:createRecord");
- createRecordEvent.setParams({
- "entityApiName": sObjectName,
- "recordTypeId": recTypeID,
- "panelOnDestroyCallback": function(event) {
- /** Check the url to know if "cancel" or "save" was pressed (if
- the url changed then save was pressed because we would have been
- redirected to the newly created record).**/
- if(windowHref !== window.location.href){
- let splitPath = window.location.pathname.split(sObjectName +"/");
- let newId = "";
- if(splitPath.length > 1){
- newId = splitPath[1].split("/")[0];
- }
- window.history.back();
- /** component.set() and get() won't work for some cases (e.g. if your
- component is a quick action) and you'll have to get creative like
- pass the id through an application event and create another component
- to handle the it. **/
- component.set("v.newAccountId", newId);
- }
- }
- });
- createRecordEvent.fire();
Add Comment
Please, Sign In to add comment