var parentItem = parent.thisItem; var value = parentItem.getProperty("item_number","")Eli
var parentItem = parent.thisItem; if (parentItem.fetchLockStatus() == "1") { // get form context var instanceFrame = parent.parent.document.getElementById("instance"); if (instanceFrame && instanceFrame.contentWindow) { instanceFrame = instanceFrame.contentWindow; alert("alert"); } // update the parent property in cache if (instanceFrame.handleItemChange) { instanceFrame.handleItemChange("description","test"); } } else { alert("Parent is not locked, or is locked by another user."); }Note that this updates the item in cache, not the server. If the user wants to save the changes to the server, they'll need to click "Save". If you want to automatically save the changes to the parent and refresh the form, you can do something like this:
var parentItem = parent.thisItem; if (parentItem.fetchLockStatus() == "1") { parentItem.setProperty("description","test1"); parentItem.setAction("edit"); parentItem = parentItem.apply(); aras.uiReShowItemEx(parentItem.getID(), parentItem.node); } else if (parentItem.fetchLockStatus() == "0") { // lock and update the parent or warn user alert("Parent is not locked. Please lock."); } else { alert("Parent is locked by another user or cannot be locked."); }Eli
instanceFrame
before calling the handleItemChange
.
The code sample below should allow you to update the value of the field without writing the value to the cache or to the database.
var itemNumberElements = parent.frames["instance"].contentDocument.getElementsByName("item_number");
// Both the parent <div> of the field as well as the <input> we want share the same name,
// so we will loop through them and only update the value of the input
itemNumberElements.forEach(function(node) {
if (node.nodeName === "INPUT") {
node.value = "123";
}
});
Chris
// Get the parent form var parent_form = parent.parent.document.getElementById("instance"); if (parent_form && parent_form.contentWindow) parent_form = parent_form.contentWindow.document; // Get the field and set the value. Use <tag_name>.<property_name> for the query selector. var field = parent_form.querySelector("input.item_number"); field.value = "123";
Hi Eli,
We have similar situation where relationship grid js code update parent data and apply them. The code above works perfectly however our parent is versionable and on edit new generation of parent item is made.
So when we use code:
aras.uiReShowItemEx(parentItem.getID(), parentItem.node);
old tab with old generation is still open plus new tab is created with new generation.
Is any way to avoid this and just refresh parent form?