Posted: 26 May 2016 0:58 EDT Last activity: 4 Oct 2018 13:54 EDT
Using Top keyword in Data Transform
In the articles that i went through https://pdn.pega.com/node/49966 and https://pdn.pega.com/node/54851 , it was mentioned that a DT cannot use Top/Parent to refer to pages. But i was able to refer a Top level page using the Top keyword. i want to know if Pega supports the Top keyword in DT's now ? (Parent keyword cannot be used anyway). Thanks
**Moderation Team has archived post**
This post has been archived for educational purposes. Contents and links will no longer be updated. If you have the same/similar question, please write a new post.
I have gone through one of the internal discussion posted by product specialist and understood that , we usually recommend against using Top in Data Transforms because the handling of "Top" can change based on when and where it is used in surprising ways.
The root cause of the problem is that "Top" is a special keyword that is not always handled by all assembly code. It will likely be handled correctly by actions such as Set, which are primarily handled by the expression parser, but may not be handled properly by other actions such as Update Page, which does not use always use the expression parser. Additionally, Top as a concept is odd and type-unsafe. Since an embedded page can be included at any point in the model, we can never accurately predict the type of Top. Further, the system does no type checking at run-time to ensure that the type of top declared on Pages & Classes matches the run-time type. It is equivalent to an unchecked cast. This lack of type enforcement can lead to anything from run-time errors to silently incorrect behaviour. Personally, I would not recommend the usage of Top, but I understand its utility when writing real world applications.
that is an interesting question and also a very interesting answer. Thank You!
From the perspective of Pega in practice, I have seen a lot of projects that just couldn't do without the Top keyword. Now, if that is discouraged (as well as explicit references to pyWorkPage), what is the alternative way to do it?
On that note, I can't really grasp why the use of the keyword Parent is also limited to a handful of rule types. From an object-oriented stand-point, it is a fundamental concept to be able to access the parent's properties and behaviour (i.e. activities / data transforms in Pega). In languages like Java You'd simply use super to access the parents attributes and methods. In Pega there is no such thing, is there?
Reading all these discussions above , can understand the use of Top keyword might vary based on context of use...so can anyone please answer Top can be used in any embedded page structure or only when the embedded page structure exists in a loop...
Thank you for posting your query on PSC. This looks like an inactive post and hence, we suggest you create a new post for your query. Click on the Write a Post button that’s available on the top right pane of this page. Once created, please reply back here with the URL of the new post.
We have also sent you a private message opening up a communication channel in case you have any further questions.