Guest User

Untitled

a guest
Jan 15th, 2019
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. var windowHref = window.location.href;
  2. var sObjectName = "Account";
  3. var recTypeID = "xxxxxxxxxxxxxx";
  4. var createRecordEvent = $A.get("e.force:createRecord");
  5. createRecordEvent.setParams({
  6. "entityApiName": sObjectName,
  7. "recordTypeId": recTypeID,
  8. "panelOnDestroyCallback": function(event) {
  9. /** Check the url to know if "cancel" or "save" was pressed (if
  10. the url changed then save was pressed because we would have been
  11. redirected to the newly created record).**/
  12.  
  13. if(windowHref !== window.location.href){
  14. let splitPath = window.location.pathname.split(sObjectName +"/");
  15. let newId = "";
  16. if(splitPath.length > 1){
  17. newId = splitPath[1].split("/")[0];
  18. }
  19.  
  20. window.history.back();
  21.  
  22. /** component.set() and get() won't work for some cases (e.g. if your
  23. component is a quick action) and you'll have to get creative like
  24. pass the id through an application event and create another component
  25. to handle the it. **/
  26. component.set("v.newAccountId", newId);
  27. }
  28. }
  29. });
  30. createRecordEvent.fire();
Add Comment
Please, Sign In to add comment