How to get Hidden Property of an Item


I have a ItenType named "Share" which has some hidden properties (hidden and hidden2 are set to true) those dont show up in ui to User. But I want to get this property in one of my Server method (C#), when I try to read this property using item.getProperty(<propertyName>) it does not give me property value instead gives me empty.

Please help,



  • Hi Vinay,

    myItem.getProperty(propertyName) checks myItem's dom (XmlDocument representation) for a node called 'propertyName' and returns the InnerText of that node, or null if no such node was found or it was empty. It does not do SQL calls to the database or anything of the sort. To get item data from the server, you need to apply() a "get" on myItem at some point before you want to access the property on it. So if myItem.getProperty(propertyName) returns null for you, the first place I'd check is where you get myItem in your server side method. Do you have any 'select' statement on myItem before applying the 'get' action? Example:

    // I'm assuming we have an Innovator object called inn
    var myPart = inn.newItem("Part", "get");
    // We want to get the part with item_numer P1:
    myPart.setProperty("item_number", "P1");
    // We restrict the server response to only include the properties 'name' and 'description':
    myPart.setAttribute("select", "name, description");
    // We apply the get:
    myPart = myPart.apply();

    // myString will be null since we did not return the item_number property, even though the item_number of the Part is, in fact, P1
    var myString = myPart.getProperty("item_number")

    If you are working with 'select' attributes, make sure that your property is included in them.

    If you are working with 'this'-item as myItem in a server-side method, you will have to make sure that the information you want to extract is present in this's dom, otherwise you will have to manually fetch that information from the server with a "get" like above.

    Hope this helps.



  • Thanks for your reply,

    I have a hidden property named "xxxxx" and I have a OnAfterGet() server event, in this event i want to read this "xxxx" property and fetch data from our REST API. But when I read this property i get null result.

    If I do query for this, it will go into infinite loop as it will fire the same event again.



  • Hi Vinay,

    it seems like 'this'-Item that you are working with in your onAfterGet-method does not include the xxxxx-Property in its dom, so you'll have to fetch that somehow. There is a "serverEvents"-attribute that you can set on an item before applying it so that the onAfterGet-method is not triggered in an endless loop:

    var myItem = inn.newItem("Share", "get");
    myItem.setAttribute("serverEvents", "0");
    myItem.setAttribute("select", "xxxxx");
    myItem.setID(this.getID());   // careful with this.getID(). When getting multiple items at the same time, for the grid view, for example, 'this' will be an item collection and 'this.getID()' will return a "Not a single item" error.
    var resultItem = myItem.apply();
    string xxxxxValue = resultItem.getProperty("xxxxx");

    I'm not entirely certain how exactly that attribute works, since it seems to only sometimes stop server events of an item from firing, and other times it does not, but please do try this out in your case when trying to fetch the property from the server.

    Alternatively, you could do a SQL-query in your onAfterGet-method. SQL-queries ignore Aras Server events, so you should not get any infinite loops, but be careful: SQL-queries also bypass Aras' permissions setup, so please use the corresponding IOM-methods if at all possible. Nevertheless, here's what the SQL query in your onAfterGet method could look like:

    string sql = "SELECT xxxxx FROM innovator.[Share] WHERE id='idOfYourItem'";
    var sqlResult = inn.applySQL(sql);
    string xxxxxValue = sqlResult.getItemByIndex(0).getProperty("xxxxx");