[SysClientCacheDataMethodAttribute(true)]
display HERoutYear HERoutYear()
{
AMDeviceTableMaster deviceTableMaster;
deviceTableMaster = this.AMDeviceTableMaster();
if (deviceTableMaster.DeRegistrationDate)
{
return int2str(year(deviceTableMaster.DeRegistrationDate));
}
// If DeRegistrationDate is empty, check EndDate in AMRentDevice
else if (this.rentalEndDate())
{
return int2str(year(this.rentalEndDate()));
}
// If both DeRegistrationDate and EndDate are empty, check HerEstimatedRentEndDate in AMDeviceTable
else if (this.HerEstimatedRentEndDate)
{
return int2str(year(this.HerEstimatedRentEndDate));
}
Additionally, i wanted to expose this field on my data entity AMDeviceOverviewEntity. Therefore, i have created a virtual field and called my display method result under the postLoad() method on the entity (as stated in MS documentation). However, virtual fields do not allow filtering in Excel OData. After some research i found on MS documentation that i should use computed fields instead but i am not able to achive that goal. I tried the below code but i am getting a build error.
tableStr(AMDeviceTable), methodStr(HERAMDeviceTableDbt_Extension, HERoutYear));
return fldMyField;