# Getting the class caller of the method for validation purpose

**URL:** <https://www.dynamicsuser.net/t/getting-the-class-caller-of-the-method-for-validation-purpose/58693>\
**Category:** Developer Forum\
**Created:** [September 30, 2015, 3:57am UTC](https://www.dynamicsuser.net/t/getting-the-class-caller-of-the-method-for-validation-purpose/58693 "2015-09-30T03:57:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![knives77](https://avatars.discourse-cdn.com/v4/letter/k/9de053/32.png) [@knives77](https://www.dynamicsuser.net/u/knives77)\
**Post date:** [September 30, 2015, 3:57am UTC](https://www.dynamicsuser.net/t/getting-the-class-caller-of-the-method-for-validation-purpose/58693/1 "2015-09-30T03:57:44Z")

</div>

Hi All,

Need your help.

Is there a way on AX 2012 to get the class caller name of specific table method?

My scenario is I need to get the class caller name of update method of salesLine table and to put validations on specific class that are calling the updateMethod.

Thank you in advance guys.

---

<div class="post-metadata">

**Author:** ![MartinDrab](https://avatars.discourse-cdn.com/v4/letter/m/e0b2c6/32.png) [@MartinDrab](https://www.dynamicsuser.net/u/MartinDrab)\
**Post date:** [September 30, 2015, 5:29am UTC](https://www.dynamicsuser.net/t/getting-the-class-caller-of-the-method-for-validation-purpose/58693/2 "2015-09-30T05:29:43Z")

</div>

You won’t get such a reference automatically - if you need it, you have to pass it to the method (or the object, if applicable) by yourself. But doing that in update() is something I consider wrong design. You should come up with more clever solution.

By the way, validateWrite() is usually a better place for validations than update().

---

<div class="post-metadata">

**Author:** ![abhinaybuiss](https://avatars.discourse-cdn.com/v4/letter/a/e95f7d/32.png) [@abhinaybuiss](https://www.dynamicsuser.net/u/abhinaybuiss)\
**Post date:** [September 30, 2015, 8:21am UTC](https://www.dynamicsuser.net/t/getting-the-class-caller-of-the-method-for-validation-purpose/58693/3 "2015-09-30T08:21:10Z")

</div>

Hi Chris,

If the Args is initialized prior to the execution of the update method, you can use [args.caller](https://msdn.microsoft.com/en-us/library/args.caller.aspx) to get the name of the caller (refer [here](http://dynamicsaxspace.com/2011/08/how-to-get-forms-caller-in-dynamics-ax/)), else you may refer to the [stacktrace](http://dynamics-ax-live.blogspot.com/2009/04/getting-stacktrace.html)as given in the link.

And I agree with Martin over

> [@](#):
>
> By the way, validateWrite() is usually a better place for validations than update()…

HTH
