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, ...
Suggested Answer

Create View with field from display method

(0) ShareShare
ReportReport
Posted on by 709

Hi guys,

Is there a possibility to create View which is the field is from a display method ?

So I create View, lets say the data source is table A and apart from adding fields from table A's field, I also want to have a field that displaying table A's display method.

A sample view from Ax is BankAccountView :

pastedimage1613357085867v1.png

So in this example BankAccountView, I would like the "getBankAccountBalanceCur" to be one of the field.

This is actually related to my other post (+) Relation between ProjTransPosting and ProjPostTransView - Dynamics 365 Finance Forum Community Forum, but it  can be separated so not really matters as the point is still "can we have a field of a View based on a display method ?"

Thanks,

I have the same question (0)
  • Suggested answer
    Ajit Profile Picture
    8,755 on at

    You can add a computed column in a view with your logic.

    docs.microsoft.com/.../walkthrough-add-a-computed-column-to-a-view

  • ShaqAX Profile Picture
    709 on at

    Hi Ajit,

    Yes, this is what I initially thought, so I create something like this:

    1. In my view, I added this method :

    public static server str projInvoiceStatus()
        {
            DictView    dictView             = new DictView(tableNum(MyView));
            str         projInvoiceStatus     = dictView.computedColumnString('ProjPostTransView', 'projInvoiceStatus', FieldNameGenerationMode::FieldList);
               
        
            return projInvoiceStatus;
        
        }

    over there, ProjPostTransView is my data source in the view, and "projInvoiceStatus" is the display method of ProjPostTransView. 

    2. On the Fields node of that view, add new String computed column and use the method no.1, specified in that field -> View Method property.

    Is this correct ?

    Using my example of BankAccount, is something like this, right ?

    DictView    dictView             = new DictView(tableNum(BankAccountView));
            str         balance = dictView.computedColumnString('BankAccountTable', 'getBankBalanceAccountCur', FieldNameGenerationMode::FieldList);
               
        
            return balance;

    something not really same is this "getBankBalanceAccountCur" on the example is a display method in the view it self while mine, the display method is in the table's side of the data source.

    Thanks,

  • Suggested answer
    Martin Dráb Profile Picture
    237,801 Most Valuable Professional on at

    You misunderstand the purpose of computed columns. The method must return T-SQL code that will calculate the value. The method will be executed on DB synchronization and T-SQL inserted to the view definition in database. It's not your code does - you're trying to return a value of getBankBalanceAccountCur field, which makes no sense.

    You must analyze what getBankBalanceAccountCur() does, rewrite it to T-SQL code and then write X++ code generating this T-SQL code.

    Obviously you can't use X++ code (including getBankBalanceAccountCur() method) in T-SQL.

  • ShaqAX Profile Picture
    709 on at

    Hi Martin,

    Yes, understood about the computed column part, also about "The method must return T-SQL code that will calculate the value. The method will be executed on DB synchronization "

    The one that I can't is to interpret what x++ did to all those SysComputedColumn function stuff. "getBankBalanceAccountCur" is not really that complex, even so I don't know how to interpret this. But my real goal is actually the method in ProjPostTransView.proInvoiceStatus(), which is far more complex.

    Any workaround to achieve all this ?

    Thanks,

  • nmaenpaa Profile Picture
    101,160 Moderator on at

    There's no workaround if your actual requirement is to create a computed column in the view. But is that your business requirement, or is that just an approach that you chose to fulfill your business requirement?

  • ergun sahin Profile Picture
    8,826 Moderator on at

    If there is a no hope, you can create a field for or a table for this and calculate before using view. But you will give up runtime functinalty and it will take a lot time. Like others I think you must create a computed column.

  • amit_s Profile Picture
    65 on at

    Hi , were you able to get this done ? I have the very same requirement and not sure how to get the display method logic into a T-SQL statement. Any help is appreciated

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

    For reference, amit_s created another thread for his/her actual question.

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

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 307 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans