Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Answered

Synchronization error on computed column

(0) ShareShare
ReportReport
Posted on by 7,048 Super User 2025 Season 1

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?

  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 230,817 Most Valuable Professional on at
    RE: Synchronization error on computed column

    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).

  • Waed Ayyad Profile Picture
    Waed Ayyad 7,048 Super User 2025 Season 1 on at
    RE: Synchronization error on computed column

    Hi Mariano,

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

  • Waed Ayyad Profile Picture
    Waed Ayyad 7,048 Super User 2025 Season 1 on at
    RE: Synchronization error on computed column

    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));

  • RE: Synchronization error on computed column

    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++

  • Martin Dráb Profile Picture
    Martin Dráb 230,817 Most Valuable Professional on at
    RE: Synchronization error on computed column

    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?

  • Waed Ayyad Profile Picture
    Waed Ayyad 7,048 Super User 2025 Season 1 on at
    RE: Synchronization error on computed column

    Hi Judy,

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

  • Waed Ayyad Profile Picture
    Waed Ayyad 7,048 Super User 2025 Season 1 on at
    RE: Synchronization error on computed column

    Hi Andre,

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

    pastedimage1675952282741v1.png

  • Verified answer
    huijij Profile Picture
    huijij 19,811 on at
    RE: Computed table vs virtual table

    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.

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,965 Super User 2025 Season 1 on at
    RE: Computed table vs virtual table

    Hi Waed,

    What is the exact error and when does this appear?

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,965 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,817 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans