Skip to content

Instantly share code, notes, and snippets.

@EliJDonahue
Created August 21, 2018 20:40
Show Gist options
  • Save EliJDonahue/f9abeaf1711b158ccfbaccb72f5db1b3 to your computer and use it in GitHub Desktop.
Save EliJDonahue/f9abeaf1711b158ccfbaccb72f5db1b3 to your computer and use it in GitHub Desktop.
Demonstrates how to determine whether a related item was picked or created
/** this method throws an alert that says whether a related item was picked or created **/
// get the parent item
var parent_item = parent.thisItem;
// get the related item
var related_item = parent_item.getItemsByXPath("//Item[@id='" + relatedID + "']");
if (related_item.getItemCount() > 1)
related_item = related_item.getItemByIndex(0);
var kn = related_item.getProperty("keyed_name","");
// check the item's isTemp attribute - will tell us whether it was created
var isNew = related_item.getAttribute("isTemp");
if (isNew)
return alert("Related Item '" + relatedID + "' was created.");
return alert("Related Item '" + kn + "' was picked.");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment