Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :

AX 2012: this vs element | When to Use What?

M Anas Khan Profile Picture M Anas Khan 1,424

In X++ we often come across an issue that we are unable to access an object member (e.g. a form method) via this keyword. Instead we CAN access the same form method via element keyword. So what’s the difference between them?

 

UntitledThe difference is of the scope. To understand how it works, let’s assume that we are standing at a button’s click method on a form and we need to access a method defined at the form level (e.g. readResourceFile() in this case). In this situation this keyword cannot access the method since its scope is only limited to the members of the current object. For example with this keyword we can access all the members of the button object. However, we can access the form-level method using the element keyword.

So element keyword has a bigger scope as compared to this keyword.



This was originally posted here.

Comments

*This post is locked for comments