Skip to main content

Notifications

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.
  • Martin Dráb Profile Picture
    Martin Dráb 230,934 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.
  • Prem Profile Picture
    Prem 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
    Martin Dráb 230,934 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.
  • GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 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.

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…

Vahid Ghafarpour – Community Spotlight

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

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,111 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,934 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans