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