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

Community site session details

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

How to Add a Display Method of a table as a filed in a View

(0) ShareShare
ReportReport
Posted on by 10
Hi All,
 
I have created a View with CustTrans as a DataSource and I need to add remainAmountMST() display method of CustTrans Table as field in my view. Can anyone help me on this.
 
Thanks In advance,
Prem Sai.
I have the same question (0)
  • GirishS Profile Picture
    27,827 Moderator on at
    How to Add a Display Method of a table as a filed in a View
    Hi Prem,
     
    I would suggest you to create a computed column for that method and map it to the field.
     
    Thanks,
    Girish S.
  • Martin Dráb Profile Picture
    237,681 Most Valuable Professional on at
    How to Add a Display Method of a table as a filed in a View
    Views are defined in database, while display methods are in the application layer written in X++. The database server know nothing about the application an X++, therefore you can't refer to such methods from T-SQL.
     
    Therefore your current technical design can't be implemented. You'll need to change your approach, e.g. by using a computed column or creating a display method for your view.
  • Prem Profile Picture
    10 on at
    How to Add a Display Method of a table as a filed in a View
    Can anyone give me T-SQL code to create the computed column for remainAmountMST() display method of CustTrans Table.
  • Martin Dráb Profile Picture
    237,681 Most Valuable Professional on at
    How to Add a Display Method of a table as a filed in a View
    Before you can even start designing your SQL code, you must look at the logic in X++. You'll find it in remainAmountMST() method of CustVendTransData class.
     
    It looks like this:
    public AmountMST remainAmountMST()
    {
        AmountMST remainAmountMST;
        
        #ISOCountryRegionCodes
        boolean countryRegion_RU = SysCountryRegionCode::isLegalEntityInCountryRegion([#isoRU]);
        
        if (custVendTrans.TransType == LedgerTransType::ExchAdjustment
            || (countryRegion_RU
                && custVendTrans.TransType == LedgerTransType::AdvanceAdjustment_RU))
        // </GEERU>
        {
            remainAmountMST = custVendTrans.AmountMST - custVendTrans.SettleAmountMST;
        }
        else
        {
            remainAmountMST = custVendTrans.AmountMST + custVendTrans.ExchAdjustment - custVendTrans.SettleAmountMST;
        }
    
        return remainAmountMST;
    }
    Then consider whether you need all the logic. For example, you can simplify your code a lot if you decide not to support the logic around AdvanceAdjustment_RU.
     
    Then I recommend writing and testing T-SQL, before writing a computed column method generating this SQL code.
     
    A piece of information that will help you is that the mapping between enum elements names and values is in EnumValueTable.

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 683 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 398 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans