getItemById including select statement possible?

Hi, I sometimes have seen code that uses getItemById with additional parameters. It seems that it´s also possible to include a select statement. Is it actually possible to do something like this? var myManufacturer = inn.getItemById("Manufacturer", myid ,0,null,"name,city"); I currently assume the following syntax: getItemById(ItemType, id, levels, something related to levels, select properties); I wasn´t able to use this one successfuly yet, as the additonal parameters were ignored in my testa. So the method will return the complete Item. Does anybody know if this one can work at all? Best regards! Angela
  • Hi Angela, You might be seeing a difference between the Server-side function that exists on the Innovator object and the Client-side function that exists on the aras object. The Server-side function accepts only two parameters: the ItemType name and the id of the item. The Client-side function on the other hand can accept more arguments such as a select statement. You can find the definition of the Client-side getItemById function in your code tree under \Innovator\Client\javascript\item_methods.js. Chris
    Christopher Gillis Aras Labs Software Engineer
  • Hi Chris, thanks for explanation! Didn´t know about the different between the server and client version. I made some very quick test with the ItemType Manufacturer:
    var manunfacturer = aras.getItemById("Manufacturer", myId ,0,undefined,"name");
    var name = aras.getItemProperty(manunfacturer, "name","empty");     
    var city = aras.getItemProperty(manunfacturer, "city","empty");
    In my version, the select statement stil seems to be ignored. The code will return both "name" and "city", also "city" is not included in the select statement. Angela
  • Hi Angela, I took a deeper look into the method code and it looks like the select is applied when the call is made to the sever. However, once the item is retrieved from the server it is not immediately returned to the user. Instead the property data is merged into the cached version of the item that exists on the client. This is why you're still able to get city even though you didn't include it in the select statement. If your use case requires that these other properties are not populated at all, you can try the sample below which will let you use an API more similar to a server method.
    var itm = aras.IomInnovator.newItem("Part", "get");
    itm.setAttribute("select", "name");
    itm.setID("C1A218EE1CF5461F964BEAED127211E6");
    itm = itm.apply();
    Chris
    Christopher Gillis Aras Labs Software Engineer
  • Hi Chris, ok, that´s really some special behavior and probably has it´s reason. The code where I have seeen the additional properties were quite special use cases. In my case, the classical and proven get queries already perfectly do the job. I do not have to make experiments everywhere. One last question: Is there any difference between these two ways to call the IOM on client side?
    var itm = aras.IomInnovator.newItem("Part", "get");
    itm.setAttribute("select", "name");
    itm.setID("C1A218EE1CF5461F964BEAED127211E6");
    itm = itm.apply();
    var inn = this.newInnovator(); 
    var itm = inn.newItem("Part", "get");
    itm.setAttribute("select", "name");
    itm.setID("C1A218EE1CF5461F964BEAED127211E6");
    itm = itm.apply();
  • Hi Angela, I think functionally those two calls would be identical. However, using aras.IomInnovator will be more generally applicable. Unlike a Server method, the this context item of a Client method doesn't have to be an Aras Item object, so you may not be able to call this.newInnovator(); from any client event. Chris
    Christopher Gillis Aras Labs Software Engineer