Skip to main content
Dynamics 365 Community / Forums / Finance forum / how to call display me...
Finance forum
Suggested answer

how to call display method to computed column in d365

editSubscribe (2) ShareShare
ReportReport
Posted on by 8
 
Hi there, i have created aggregate measure for SalesOrderLineV2Entity and
duplicated SalesOrderLineV2Entity & created one computed column Invoiced real field in it. 
Now, Invoiced is the field which is called through display method (InvoicedInTotal) of salesline table on the SalesTableLineQuantiy form.
How to call this method  for DataEntityViewMethod?
 
related to this display method found  this one code of salelinetype class, 
Attachments
  • Suggested answer
    Layan Jwei Profile Picture
    Layan Jwei 2,858 Super User on at
    how to call display method to computed column in d365
    Hi,

    Here's an example of how to write one:
    just replace it with your query
     public static server str Id()
        {
    
            return  strFmt('select top 1 Id from Table1 as table1 WHERE table1.PARTITION = %1 AND table1.DATAAREAID = %2 AND table1.ParmId = %3 AND table1.Id != %4'
                , SysComputedColumn::comparisonField(tableStr(EntityTable1), identifierStr(Table1), fieldStr(Table1, Partition))
                , SysComputedColumn::comparisonField(tableStr(EntityTable1), identifierStr(Table1), fieldStr(Table1, DataAreaId))
                , SysComputedColumn::comparisonField(tableStr(EntityTable1), identifierStr(Table1), fieldStr(Table1, ParmId))
                , SysComputedColumn::comparisonField(tableStr(EntityTable1), identifierStr(Table1), fieldStr(Table1, Id))
                 );
    
        }

    Thanks,
    Layan Jweihan
    Please mark this answer as "Verified" if it solved your issue. In order to help others who will face a similar issue in the future
  • Martin Dráb Profile Picture
    Martin Dráb 222,727 Super User on at
    how to call display method to computed column in d365
    That's because your SQL code is invalid. Remove the + sign in front of where. You'll also likely have to prefix the field name with a table name. It's beneficial to test the SQL code before using it in a computed column.
     
    A serious bug in your code is that you don't take DataAreaId (and Partition) into account.
     
    Also, don't hard-coded application object names, such as CustInvoiceTrans. Use intrinsic methods like tableStr(). The compiler will check correctness of such names and cross references will will be recorded for the usage.
     
  • M_R Profile Picture
    M_R 125 on at
    how to call display method to computed column in d365
    I have written code like this, but having sync failed to database error
     
     
  • Suggested answer
    Navneeth Nagrajan Profile Picture
    Navneeth Nagrajan 1,184 on at
    how to call display method to computed column in d365
    Hi,
     
    Agree with what Martin says. You will have to rewrite this code either in a computed column directly (which is the best possible scenario) or else use virtual fields and invoke them through postLoad() method (very bad for performance) or in mapEntitytoDataSource methods in the data entity. 
     
     
  • how to call display method to computed column in d365
    yes, but we are creating this for entity store
     
  • Suggested answer
    Waed Ayyad Profile Picture
    Waed Ayyad 2,029 on at
    how to call display method to computed column in d365
    Hi,
     
    As Martin mentioned the way that you write the code isn't correct. Check the following blogs:
     
    Thanks,
    Waed Ayyad
    If this helped, please mark it as "Verified" for others facing the same issue
     
  • Martin Dráb Profile Picture
    Martin Dráb 222,727 Super User on at
    how to call display method to computed column in d365
    A computed column methods returns SQL code to be injected in a SQL view definition. The method shown above doesn't generate SQL code, therefore it's not useful in your scenario. You'd have to rewrite this X++ code to SQL and then write X++ code generating this SQL.

    A potential alternative is using a virtual field instead of a computed column. Easier to implement, worse for performance.

Helpful resources

Quick Links

New Blog Features Released!

Check out the new community blog features for viewers and authors…

Setting Up Knowledge Sources for Copilot…

Look at how configuring a comprehensive knowledge base is crucial…

Demystifying Copilot with Georg Glantschnig…

Industry experts answer burning questions directly from our amazing Community…

Leaderboard

#1
Andre Arnaud de Calavon Profile Picture

Andre Arnaud de Cal... 283,176 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 222,727 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,138

Featured topics

Product updates

Dynamics 365 release plans