Created
August 21, 2018 20:38
-
-
Save EliJDonahue/648abcb69d54d385eb99a1a13fb5f894 to your computer and use it in GitHub Desktop.
Demonstrates how to update a source item via grid event
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 updates the parent's assigned creator based on the related item's assigned creator **/ | |
// get the parent item | |
var parent_item = parent.thisItem; | |
// get the related item and its creator | |
var related_item = parent_item.getItemsByXPath("//Item[@type='Part' and @id='" + relatedID + "']"); | |
if (related_item.getItemCount() > 1) | |
related_item = related_item.getItemByIndex(0); | |
var related_user = related_item.getProperty("owned_by_id", ""); | |
// if the related item's assigned creator is *not* set, return | |
if (related_user === "") | |
return; | |
// get parent form context | |
var instanceFrame = parent.parent.document.getElementById("instance"); | |
if (instanceFrame && instanceFrame.contentWindow) { | |
instanceFrame = instanceFrame.contentWindow; | |
} | |
// update the parent property in cache | |
if (instanceFrame.handleItemChange) { | |
instanceFrame.handleItemChange("owned_by_id",related_user); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment