Wednesday, August 30, 2023

How to use Display Method in AX

 

How to use Display Method in AX 2012 && Dynamic 365 

Sometimes developer has requirement to show data on selecting some record. This can be achieved using display method. It saves memory space as we don't need to insert record in another tables to use data. Here I'm giving an simple example on how to use display method in axapta.

Example:

  • Crate two tables WRE_TableA and WRE_TableB
  • Create two fields in WRE_TableA  Id and Name.
  • Create a field in WRE_TableB Id.
  • Now create a relation as shown below.





  • Create a display method getNameMethod and write following code.


    Display Name getNameMethod()
{

    WRE_TestTableA   wRE_TestTableA;

    select Name From WRE_TestTableA
      where wRE_TestTableA.ID == this.Id;


   return WRE_TestTableA.Name;

}

  • Now create a Form to test display method
  • Add TableB in Data Source of form
  • Drag Id field to design and create new string field Name and change property.
  • Make DataSource as TableB and DataMethod as getNameMethod.






                                          
  • Insert some dummy records in Table




  • Now open form and select any record


  • Similarly, you can also try with some standard table.

 Thank you @18

No comments:

Post a Comment

How To Create A WorkFlow In D365F&O

  How To Create Work Flow In D-365 F&O ? What is workflow? A workflow in the dynamics 365 apps is a way that automate business processes...