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, ...
Answered

How to display method in form ?

(0) ShareShare
ReportReport
Posted on by

Hi All,

1. Created a table ABC_DS with field XYZ_fld which will be lookup field of another table and a display method xyz() which is description of  XYZ_fld.

2. Created a form where I have added field XYZ_fld and method xyz() in grid.

3. Now want to display value in method xyz() when user selects/modify value in XYZ_fld. But Description is not displaying. 

Please Kindly suggest me where I'm lacking to achieve this. 

Regards,

Aimon Fatima

I have the same question (0)
  • Suggested answer
    Pete Alberts Profile Picture
    3,542 on at

    There isn't much more to it than that... Your implementation seems correct. If i were you I'd just go through everything again step by step to see if you missed some sort of property. And then build your project again and maybe "restore" the form.

    A wild guess: Did you remember the "display" keyword on your display method?

  • nmaenpaa Profile Picture
    101,160 Moderator on at

    Could you please share the code of your display method?

    Does the display method / field work on records that already exist on the grid?

    Also, does it start displaying the value on new record after the user saves the record?

  • Suggested answer
    Pete Alberts Profile Picture
    3,542 on at

    On second thought. I am worried you did something strange. Here are some steps:

    1. On your table, add your method like the example below.
    2. On your form, create a String control where you need it.
    3. Specify the Datasource and Data method properties. Screenshot supplied below.

    That is it. Nothing more to it.

    class XYZMyTable extends Common
    {
        [SysClientCacheDataMethod] //BP check
        display Description myDisplayMethod()
        {
            Description myDisplayMethod;
            
            myDisplayMethod = *some logic, probably including a find method*;
            
            return myDisplayMethod;
        }
    }
    Screenshot-2020_2D00_04_2D00_14-at-17.34.34.png

  • Community Member Profile Picture
    on at

    Ya. I have done all these steps.

    I got the problem, that datasource of not refreshing at the moment so I have  refresh by datasource at modified method of field.

    Thanks for the response..

  • Community Member Profile Picture
    on at

    Thanks for the response Nikolaos..

    Ya. In display method I have passed my table buffer, so that it will get the current record and display the description against that record and  refresh my datasource after executing of this code.

  • nmaenpaa Profile Picture
    101,160 Moderator on at

    Did you notice my question about sharing your code?

  • Community Member Profile Picture
    on at

    ohh..I missed it. Sharing my code below which I have created in my XYZ_table table

    [SysClientCacheDataMethodAttribute(true)]

       public display Description displayDescription(XYZ_table  _XYZ_table )

       {

          ABC_table                abc_Table;

           select firstonly Description from abc_Table

               where abc_Table.XYZ_field   ==  _XYZ_table .XYZ_Field;

           return abc_Table.Description;

       }

  • Verified answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    Remove the caching attribute and it will work. If caching is used, display methods are refreshed only when data is updated and this happens only when the user saves the record that they are working on.

  • Verified answer
    Pete Alberts Profile Picture
    3,542 on at

    I think you should revisit your OOP. If I need your email address - I don't need to ask you "What is Almon's email address?", but rather "What is your email address?". The same with XYZ_Table. You already have an instance of the object. It is not necessary (and wrong) to specify the XYZ_Table instance from which you want the description.

    Maybe you confused display methods on form datasources with this. In that case it makes sense that you need a parameter. In this case it does not.

    So the correct code will be like this:

    [SysClientCacheDataMethod(true)]
    display Description displayDescription()
    {
        Description displayDescription;
        
        //side note - this should be a find method
        ABC_Table lookupTable;
        select firstonly Description from lookupTable where
            lookupTable.XYZ_Field == this.XYZ_Field;
        displayDescription = lookupTable.Description;
        
        return displayDescription;
    }

  • Community Member Profile Picture
    on at

    Thank you...

    Ya its working now .

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

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 303 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans