Create display mehtod in D365 X++

 Create a “display”  method for the table extension.

As you all aware that we cannot customize any standard table, so you have to create extension of the related table.

Example:

you have to add a display method to the SalesQuotationTable

It can be achieved by using the extension class.

Step 1: Create a new class and name it as <Classname>_<Extension>.

<Class-name> – can be any name, but it is preferred to give the table name for which the extension is being created. 

postfix <_Extension> is must.

public static class SalesQuotationTable_Extension

{

}

Step 2 : Now add the display methods in the class which is required to be shown.

public static class SalesQuotationTable_Extension

{

[SysClientCacheDataMethodAttribute(true)] //This attribute will cache your display method.
public static display Name getFOB(SalesQuotationTable _this)
{
Name getName;
InventLocation inventLocation = InventLocation::find(_this.InventLocationId);

LogisticsPostalAddress logisticsPostalAddress = LogisticsLocationEntity::findPostalAddress(inventLocation, LogisticsLocationRoleType::None,DateTimeUtil::utcNow(),NoYes::Yes);

if (logisticsPostalAddress.State)
{
getName = logisticsPostalAddress.City +’,’+ logisticsPostalAddress.State;
}
else
{
getName = logisticsPostalAddress.City;
}

return getName;
}

}

Step 3: To use this display method in the form.

Create a string control in the form design and set the following properties

Data source: SalesQuotationTable

DataMethod: SalesQuotationTable_Extension::getFOB

CacheDataMethod: Yes

Below is the screen shot for reference.

xc

Step 4: Build/Rebuild the project/solution and check the output in the URL.

Comments