Get parent form field value with javascript

オフライン
From javascript fired from relationship grid, how to get the value of a field in the parent form? parent.thisItem.getItemById("X"); top.aras.getItemById("X"); getFieldByName("X").getElementsByTagName("input")[0].value;
Parents
  • Hello, 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 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
    Christopher Gillis Aras Labs Software Engineer
Reply
  • Hello, 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 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
    Christopher Gillis Aras Labs Software Engineer
Children
No Data