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

Notifications

Announcements

No record found.

Community site session details

Community site session details

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

Synchronization error on computed column

(0) ShareShare
ReportReport
Posted on by 9,039 Super User 2025 Season 2

Hi All,

I am trying to add new computed field to standard data entity, what I want to return to this field NO or Yes based on if current record has data in related table (I want to do select statement to find if current record has related data  and return yes or no based on it . I am truing this but synchronization issue appear 

return SysComputedColumn::if(
SysComputedColumn::isNotNullExpression(expression),
SysComputedColumn::returnLiteral(NoYes::Yes),
SysComputedColumn::returnLiteral(NoYes::No));

expression contain sql statement to check if it has data in the related table.

Any hint?

I have the same question (0)
  • André Arnaud de Calavon Profile Picture
    301,075 Super User 2025 Season 2 on at

    Hi Waed,

    What is the exact error and when does this appear?

  • Verified answer
    huijij Profile Picture
    19,811 on at

    Hi,

    As mentioned, please provide us with the more details.

    Please check SysComputedColumn class in MS document:

    learn.microsoft.com/.../gg945162(v=ax.60)

    And the method isNotNullExpression() is not mentioned in the class.

    Nevertheless, it is recommended that you split the 3 expressions in if condition, and then debug to see the root cause of the error.

  • Waed Ayyad Profile Picture
    9,039 Super User 2025 Season 2 on at

    Hi Andre,

    this is the error  and appear when I am trying to build and sync code

    pastedimage1675952282741v1.png

  • Waed Ayyad Profile Picture
    9,039 Super User 2025 Season 2 on at

    Hi Judy,

    Can I debug it? I tried to export data and put break points, but the debugger did not hit. Any hints?

  • Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

    It would help if you shared all your code and the result of the method. The problem is likely caused by what you have in the expression, which you told nothing about.

    But from what I know, your code looks logically wrong to me. The expression DirPartyView.RoleType = 1 will never return NULL, will it?

  • Mariano Gracia Profile Picture
    on at

    Write a simple runnable class, call the method and print the result in a screen, in the end is a string with the SQL syntax that will be added into the entity, which is a view in SQL, I do it each time I have to write a computed column, execute the query in SQL management studio (take notice that you'll have to add the query to the underneath sql code from the view), this way you'll see where is the error, fix it and then you'll know what to do in x++

  • Waed Ayyad Profile Picture
    9,039 Super User 2025 Season 2 on at

    Hi Martin,

    this the code that I call on Computed field:

           str expression;

           str roleTypeValue = SysComputedColumn::returnLiteral(DirPartyRoleType::Customer);

           expression = strFmt(@"SELECT DirPartyView.RecId FROM DirPartyView

               JOIN DIRPARTYTABLE on DirPartyView.PARTY = DIRPARTYTABLE.RECID

               WHERE DIRPARTYTABLE.PARTYNUMBER = %1

               and DirPartyView.RoleType = %2",

               SysComputedColumn::returnField(tableStr(DirPartyV2Entity),

               dataEntityDataSourceStr(DirPartyV2Entity, DirPartyBaseEntity), fieldStr(DirPartyV2Entity,

              PartyNumber)), roleTypeValue);

           return SysComputedColumn::if(

           SysComputedColumn::isNotNullExpression(expression),

           SysComputedColumn::returnLiteral(NoYes::Yes),

           SysComputedColumn::returnLiteral(NoYes::No));

  • Waed Ayyad Profile Picture
    9,039 Super User 2025 Season 2 on at

    Hi Mariano,

    Yes I tried it on SQL and it is working from SQL

  • Verified answer
    Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

    I think it doesn't generate correct SQL code - you need to put the subquery to parentheses. For example:

    str roleTypeValue = SysComputedColumn::returnLiteral(DirPartyRoleType::Customer);
    
    str expression = strFmt(@"SELECT DirPartyView.RecId FROM DirPartyView
        JOIN DIRPARTYTABLE on DirPartyView.PARTY = DIRPARTYTABLE.RECID
        WHERE DIRPARTYTABLE.PARTYNUMBER = %1
        and DirPartyView.RoleType = %2",
        SysComputedColumn::returnField(tableStr(DirPartyV2Entity),
        dataEntityDataSourceStr(DirPartyV2Entity, DirPartyBaseEntity), fieldStr(DirPartyV2Entity, PartyNumber)),
        roleTypeValue);
    
    return SysComputedColumn::if(
        SysComputedColumn::isNotNullExpression(strFmt('(%1)', expression)),
        SysComputedColumn::returnLiteral(NoYes::Yes),
        SysComputedColumn::returnLiteral(NoYes::No));

    By they way, please use Insert > Code to paste code to this forum (as I did).

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

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
Martin Dráb Profile Picture

Martin Dráb 551 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 278 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans