Notifications
Announcements
No record found.
Hi all,
Anyone can give me some understanding why computed column should always be a string ?
Noted in Microsoft Docs also specify this, but I just want to know the reason for this ?
https://docs.microsoft.com/en-us/dynamics365/fin-ops-core/dev-itpro/data-entities/data-entity-computed-columns-virtual-fields#properties-of-unmapped-fields
Thanks,
Hi,
The computed column is not always string. It could be Int, Int64, Real, Enum etc.
The computed field data method, however, should return a string value as it is CAST into the desired data type. The method is converted into TSQL as per the link you provided.
You can check SalesInvoiceHeaderV2Entiity\TotalDiscountAmount field as an example of a computed field of data type Real.
Hello
As Gujan said, computed columns are not always a string. It contains the "result" of a computed columns "method", this one bound on the view by a property of the computed field.
On the other hand, the computed column method should return always a string because the result of its return during synchronization process, will be the SQL code part to execute for the column on the global SQL query of the view. A computed column method is also not something to code for a X++ execution but something to write SQL expression (by using SysComputed class framework for instance).
For this kind of object and for training, I suggest to edit in SQL some views with computed columns with SSMS to see the result of the synchronization.
Hope it helps.
Jérémy.
The computed column definition must be a string because it must return a T-SQL statement that is then executed to populate the values to the actual computed column.
Unlike display methods, which contain code and return some value, the computed column x++ definition returns "code" (T-SQL) statement. The x++ code is executed in db sync, unlike a display method which is executed during runtime. In computed columns the T-SQL statement is the code that is executed during runtime (in the database).
What Nikolaos said. It's important to understand the computed column's _method_ will NEVER execute when the view is used. It's executed ONCE when the database sync runs, and its output goes straight into the SQL view's statement. It is not dynamic... The string you produce will be executed in SQL every time the view executes.
I blogged about this many years ago when this feature was introduced in AX2012. This information is still accurate: daxmusings.codecrib.com/.../computed-view-columns-in-ax-2012.html
I myself learnt about computed columns many years ago from this link daxmusings.codecrib.com/.../computed-view-columns-in-ax-2012.html and I confirm this is still valid - very well explained.
I also documented my understanding here https://daxture.blogspot.com/2015/03/computed-columns-in-views-dynamics-ax.html
However, read through MS docs article too to get initial understand and understand comparisons.
docs.microsoft.com/.../data-entity-computed-columns-virtual-fields
Thank you all for your kind explanation.
Much appreciated.
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Martin Dráb 592 Most Valuable Professional
André Arnaud de Cal... 478 Super User 2025 Season 2
BillurSamdancioglu 305 Most Valuable Professional