Aras Itemtype server events behavior

Hi all,

i am trying to understand behavior of server events attached to an Itemtype,

Let us say "add_prefix_to_document_name" is a method which is present on onBeforeGet event of Document itemtype,
now, when i load any Part  for ex : ABCD is a Part, which contains 25 documents attached to it,
so, the "add_prefix_to_document_name" should get called for 25 times but it is getting called only once... why is this happening ?
is my understanding wrong about this ? please help

Thanks in advance,
  • Hi Lokesh,

    Your understanding is incorrect in a couple ways. The AML query that would run when you get your Part with the 25 documents attached looks something like this.

        <Item type="Part" action="get" id="YOUR_PART_ID">
                <Item type="Part Document" action="get">
                        <Item type="Document" action="get"></Item>

    As you can see in this example, there's only one actual Get request being made for the Document ItemType, so the onBeforeGet server event is only called once.

    Additionally, the onBeforeGet server event might not be the one you're actually looking for. onBeforeGet events are run before the query to the server is actually made. Because of this, they are usually used for query validation like making sure that some filter is always applied when a get request is run.

    Based on the name of the method you're running, it sounds like you're trying to modify the data before it's returned to the user. This would best be done in an onAfterGet event which is used for data validation on the items that are returned to the database.

    Could you also further clarify your overall use case? There might be an alternative way that's better than using a server event at all. 


    Christopher Gillis

    Aras Labs Software Engineer