Forum Discussion
8 Replies
- eli_donahueCommunity ManagerHi bdc604, You should be able to access the parent item's properties like this:
var parentItem = parent.thisItem; var value = parentItem.getProperty("item_number","")Eli
Eli Donahue Aras Labs Software Engineer - Former_MemberAccelerator IIInice, thank you. is there a trick to get the reverse (setProperty) to work as well? var parentItem = parent.thisItem; parentItem.setProperty("item_number","123")
- Former_MemberAccelerator IIIStill trying to figure this out, any suggestions for setting parent form input fields from javascript triggered by relationship grid? parent.document.getElementById('item_number').value = "123";
- eli_donahueCommunity ManagerHi bdc604, Something like this may work for you. I tested it in 11 SP12, so you may see different behavior if you're using an older version of Innovator.
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
Eli Donahue Aras Labs Software Engineer- jancvIdeator II
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?
- Former_MemberAccelerator IIIGood examples for writing to cache or ARAS database, got both working. Still confused how to simply change the value of a field on the parent form (not cache or database). example: parent.document.getElementById("item_number").value = "123";
- christopher_gillisCommunity ManagerHello, The data in the form is stored inside of an <iframe>, so you will not be able to access the fields on the form without first entering the context of that <iframe> like Eli did in his example where he first referenced the
instanceFramebefore calling thehandleItemChange. 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.
Chrisvar 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"; } });
Christopher Gillis Aras Labs Software Engineer - eli_donahueCommunity ManagerQuick note: The "contentDocument" object only exists when using Chrome. You can use this instead to support Chrome, IE, and FF:
// 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";