Forum Discussion

Former_Member's avatar
Former_Member
Accelerator III
8 years ago

Server events

If there a way to check inside a server side method which server event called the method?

5 Replies

  • Hello, Could you please clarify your use case for retrieving the name of the server event within the method itself? While it's not easily possible to directly get the name of the server event, it may be possible to infer which server event is currently running based on the information in the context item of the method. Chris ______________________________________ Christopher Gillis Aras Labs Software Engineer
  • I have a snippet of code that exists in a methods that is attached to two server events but only want to run it in one.
  • A couple ways to check is by the "event" of the method...(beforeUpdate, beforeAdd, afterPromote, etc).  There is an order of operation, i believe, as to what events get fired off first.  If they are both the same event then you can look at the sort order.  The execution of methods, as i understand it, goes in order per type.  so lowest "sort order" goes first for each event example: onBeforeAdd_Method_1 - sort order 10 goes first onBeforeAdd_Method_1 - sort order 20 goes second etc... or, if you are able to, enable debugging and put a break point in each method.  see what gets hit first. does this help?
  • Hello, Could you please further elaborate on your use case? Which two server events do you need to distinguish between? Chris __________________________________ Christopher Gillis Aras Labs Software Engineer