web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Cannot have postLoad() method when change tracking is enabled on the F&O entity

(2) ShareShare
ReportReport
Posted on by
Hi Team,
 
I have a custom entity in which I have created two virtual fields and one postload method. I m trying to enable /Allow row version change tracking / setting it to yes but I am getting the error Cannot have postLoad() method when change tracking is enabled on the F&O entity.
 
Please help on priority how I can achieve this.
 
Thanks
 
I have the same question (0)
  • André Arnaud de Calavon Profile Picture
    301,551 Super User 2025 Season 2 on at
    Hi Karuna,
     
    Instead of virtual fields with the X++ coding on the postLoad method, there is also an option to use computed fields that can be filled with T-SQL. See also the documentation: Computed columns and virtual fields in data entities - Finance & Operations | Dynamics 365 | Microsoft Learn 
  • Karuna Dogra Profile Picture
    on at
    Thank you for response Andre,
     
    Can you please help with an example, the example in the link is quite difficult.
    In my scenario,  I have created a custom entity for whsinventtable and created two computed columns called strfilterCode and strFilterGroup. I want to store filtercode and filterGroup array field value to these virtual fields. How will I do that in case of computed caolumns ?
  • Suggested answer
    Martin Dráb Profile Picture
    238,208 Most Valuable Professional on at
    A computed column method generates a piece of SQL code which is then put to the underlying SQL view. Therefore you need to think about what you want to achieve, how you to write it in SQL and then you can write X++ code generating this SQL code.
     
    Array fields are implemented as separate fields in the database; e.g. FilterCode, FilterCode2_, FilterCode3_ and so on.
     
    I don't know what you want to do with these fields, but if you want to concatenate values with a delimiter (e.g. comma), you can utilize CONCAT_WS() function in T-SQL. E.g.  CONCAT_WS(',', T1.FilterCode, T1.FilterCode2_).
  • Karuna Dogra Profile Picture
    on at
    Thanks for responding Martin,
     
    Actually my requirement is that I have created a custom entity for whsinventtable and I created two computed columns called strfilterCode and strFilterGroup.
     
    I want to store filtercode and filterGroup array field value to these string computed columns. Now in the computed column method, how I can fetch the value of the fields filtercode and filterGroup(which are array) and show those values as string in my new fields?

    Earlier I created virtual fields in my data entity instead of computed columns and wrote the below code in my postload() method and it worked fine in data export and import, but it failed when I enabled the property "
    "Allow row version change tracking"".
     public void postLoad()
        {
            super();
    
            for (int i = 1; i <= dimOf(this.FilterCode); i++)
            {
                str filterCode = this.FilterCode[i];
    
                if (filterCode && this.StrFilterCode)
                {
                    this.StrFilterCode += ',';
                }
    
                this.StrFilterCode += filterCode;
            }
    
            for (int i = 1; i <= dimOf(this.FilterGroup); i++)
            {
                str filterGroup = this.FilterGroup[i];
    
                if (filterGroup && this.strFilterGroup)
                {
                    this.strFilterGroup += ',';
                }
    
                this.strFilterGroup += filterGroup;
            }
        }
    
    }
     
    Thats is why as suggested in thread I am trying to achieve this with computed columns but not able to understand the x++ / T-SQL code part in this scenario. During export and import through data management, I want to fetch and import these array field as string.
     
    Please help.
  • Martin Dráb Profile Picture
    238,208 Most Valuable Professional on at
    I'm not sure what you mean by "not able to understand the x++ / T-SQL code part in this scenario". First of all, did you get what a computed column is? It's covered in the first sentence of my previous reply. If not, let's look at the basics in a slower pace. If you do, please explain your actual problem, because "don't understand x++ / T-SQL code part " is too vague.
  • Karuna Dogra Profile Picture
    on at
    Thank you Martin, what I want to achieve is that I want to write method for computed column 'strFilterCode' in which I want to return the array field "FilterCode" value as string. I need help with the code for this conversion in computed column method.
  • Martin Dráb Profile Picture
    238,208 Most Valuable Professional on at
    Yes, I know and I already gave quite a lot of information about it.
     
    You didn't tell how you want to combine, therefore it's not clear whether my suggestion (utilizing CONCAT_WS()) meets your requirements or on. If it does, use it. If not, either design a different solution or - if you don't know how - tell us what you actually need.

    There is no point continuing with more steps until you define what the computed column should do.
  • Karuna Dogra Profile Picture
    on at
    Thank you Martin and Sorry I will explain the requirement-
     
     The team wants to use this custom data entity which I created for WHSInventTable for import and export through data management and for synapse as well, also the property "Allow row version change tracking"" should be enabled.
     
    Problem is that-
    -the field filtercode and filtergroup are array field, but we need these fields values as string not as array. Hence I have created two computed columns in the data entity named as strFilterCode and strFilterGroup. So that I can convert the array values of fields(filtercode and filterGroup) to string. Hence, they can be exported/imported as string in these computed column.
     
    I need your help with writing method (code) for these computed column - (in this method the value should be converted from array to string and when exported through data management the data should come as string in these computed columns. Example-
    FilterCode FilterCode2_ FilterCode3_ FilterCode4_ FilterGroup FilterGroup2_ strFilterCode strFilterGroup
    Tyres 20 30   G1   Tyres,20,30 G1
    Cycle 10     G3 G4 Cycle,10 G3,G4
     
    Like above the data should be exported .
     
    Please help.
     
  • Martin Dráb Profile Picture
    238,208 Most Valuable Professional on at
    I think CONCAT_WS() will meet your requirements if you convert empty values to NULL. For example:
     
    select CONCAT_WS(',', NULLIF(FilterCode, ''), NULLIF(T1.FilterCode2_, '')) from WHSInventTable
     
    Please test this SQL and confirm that it's what you want. If so, we can start talking about X++ to generate this SQL.
  • Karuna Dogra Profile Picture
    on at
    Thank you Martin,
     
    Yes that is what I need, below sql query is giving expected result(I removed T1 from command as it was throwing an error)

    select CONCAT_WS(',', NULLIF(FilterCode, ''), NULLIF(FilterCode2_, '')) from WHSInventTable.
     
    Please help how this can be achieved through x++ computed method.
     
    Thanks a ton.

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.

Helpful resources

News and Announcements

Season of Giving Solutions is Here!

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Abhilash Warrier Profile Picture

Abhilash Warrier 763 Super User 2025 Season 2

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 413 Super User 2025 Season 2

#3
Martin Dráb Profile Picture

Martin Dráb 284 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans