"this" vs. "element" keyword in X++
Asked Answered
H

2

21

When writing code in X++ you sometimes need to reference this.functionYouWant() and sometimes it is element.FunctionYouWant(). Sometimes both are in scope. I often try one and if the function I want isn't there I try the other. Is there a rule that explains when to use this and when to use element?

Hooge answered 23/11, 2010 at 20:8 Comment(0)
L
41

this can be used in any objects to reference the current object and member methods.

MorphX forms and reports are composite objects.

In forms the collection of objects is contained within a FormRun object. You can reference members in the outer FormRun object by using the element reference.

If your code is placed at the top level there are no functional difference between this and element.

If your code is placed in a FormDataSource this will reference the datasource but element will reference the FormRun.

Librate answered 23/11, 2010 at 21:35 Comment(0)
R
0

"This" can be used only refers to the same class objects but "element" is access the form methods into any form level(like datasouce level,design level)if the functionality of method is same we can use

Rountree answered 22/6, 2016 at 9:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.