Getting an item property in onChangedCell from a recently created relationship vs existing relationship

I'm running a method on the property event "onChangedCell". When the method is called on a newly created related item, the following statement successfully get's the property:

var my_item = parent.item.querySelector("#" + relatedID);
var my_property = aras.getItemProperty(my_item, "my_property");

The problem though is when a user edits the cell of an existing related item, I don't get the related item with the query selector. How do I handle the different scenarios of the related item being newly created and the related item being loaded since it is an existing relationship? Since the user just finished changing the property I figured that property at least would be in the cache similar to a newly created item but I'm obviously missing something.

Thank you in advance!

-Ken

Parents
  • Hi Ken,

    I tried running this in an 11.0 SP15 instance I have installed locally, and I was able to get the existing related item using your sample above. I think the issue you may be running into is that the querySelector needs special formatting for IDs that begin with a number. You can see the sample below for how you might handle these kinds of IDs.

    var my_item;

    var firstChar = relatedID.substring(0, 1);
    if (isNaN(parseInt(firstChar)))
    {
    my_item = parent.item.querySelector("#" + relatedID)
    }
    else
    {
    // If the ID begins with a number, we need to escape that character
    firstChar = "\\3" + firstChar;
    var restOfId = relatedID.substring(1);
    my_item = parent.item.querySelector("#" + firstChar + " " + restOfId);
    }

    var my_property = aras.getItemProperty(my_item, "item_number");
    alert(my_property);

    Chris

    Christopher Gillis

    Aras Labs Software Engineer

Reply
  • Hi Ken,

    I tried running this in an 11.0 SP15 instance I have installed locally, and I was able to get the existing related item using your sample above. I think the issue you may be running into is that the querySelector needs special formatting for IDs that begin with a number. You can see the sample below for how you might handle these kinds of IDs.

    var my_item;

    var firstChar = relatedID.substring(0, 1);
    if (isNaN(parseInt(firstChar)))
    {
    my_item = parent.item.querySelector("#" + relatedID)
    }
    else
    {
    // If the ID begins with a number, we need to escape that character
    firstChar = "\\3" + firstChar;
    var restOfId = relatedID.substring(1);
    my_item = parent.item.querySelector("#" + firstChar + " " + restOfId);
    }

    var my_property = aras.getItemProperty(my_item, "item_number");
    alert(my_property);

    Chris

    Christopher Gillis

    Aras Labs Software Engineer

Children