Created
August 21, 2018 20:40
-
-
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 file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** 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