Display methods in AX Extension Table (Dynamics 365)
Steps:
1. Create a class and set a name like <"TableName" and "_" and "Extension" > (Example: PurchTable_Extension)
2. Class should be a static class and public access specifier.
3. Add this attribute [SysClientCacheDataMethodAttribute(true)] for each display method header.
4. Display method should be a static method and public access specifier.
5. Only one parameter that should be that particular table name.
6. Go to that particular form, Create one field and set the datasource property as the above mentioned table and in datamethod property, Type like ClassName::MethodName.
(Ex: HcmWorker_Extension::dispWorkerPositionTitle)
Example X++ Code:
//This method is used to find the Position title of current worker.//
public static class HcmWorker_Extension
{
// BP deviation documented
[SysClientCacheDataMethodAttribute(true)]
public static display HcmTitleId dispWorkerPositionTitle(HcmWorker _this)
{
HcmPositionWorkerAssignment workerAssignment;
HcmPosition hcmPosition;
HcmPositionDetail hcmPositionDetail;
select firstonly worker, Position from workerAssignment
where workerAssignment.Worker == _this.RecId
join recid from hcmPosition
where hcmPosition.RecId == workerAssignment.Position
join Title, Position from hcmPositionDetail
where hcmPositionDetail.Position == hcmPosition.RecId;
return HcmTitle::find(hcmPositionDetail.Title).TitleId;
}
}
Steps:
1. Create a class and set a name like <"TableName" and "_" and "Extension" > (Example: PurchTable_Extension)
2. Class should be a static class and public access specifier.
3. Add this attribute [SysClientCacheDataMethodAttribute(true)] for each display method header.
4. Display method should be a static method and public access specifier.
5. Only one parameter that should be that particular table name.
6. Go to that particular form, Create one field and set the datasource property as the above mentioned table and in datamethod property, Type like ClassName::MethodName.
(Ex: HcmWorker_Extension::dispWorkerPositionTitle)
Example X++ Code:
//This method is used to find the Position title of current worker.//
public static class HcmWorker_Extension
{
// BP deviation documented
[SysClientCacheDataMethodAttribute(true)]
public static display HcmTitleId dispWorkerPositionTitle(HcmWorker _this)
{
HcmPositionWorkerAssignment workerAssignment;
HcmPosition hcmPosition;
HcmPositionDetail hcmPositionDetail;
select firstonly worker, Position from workerAssignment
where workerAssignment.Worker == _this.RecId
join recid from hcmPosition
where hcmPosition.RecId == workerAssignment.Position
join Title, Position from hcmPositionDetail
where hcmPositionDetail.Position == hcmPosition.RecId;
return HcmTitle::find(hcmPositionDetail.Title).TitleId;
}
}