Adding Symbol Font Icons to a Grid in Dynamics 365



Adding a symbol icon on a grid can be a useful way to provide information to end users and to make the information a bit more visually appealing. 

To do this, first select a symbol you want from the relevant symbol font, which can be found at the link below. This is also useful to keep track of new and changing symbols in every new version.




Add some fields and create a new “Image” control on the grid.

We will now create a display method that can be used from the LogisticsPostalAddress DataSource. We don’t want to overlay the table, we want to extend it. To do this, create a final class with a name that ends in “_Extension”. Decorate it with the “ExtensionOf” attribute so that the compiler can handle it.  We are going to create a display method that returns a container.


Here’s the sample code:

[ExtensionOf(tableStr(PurchLine))]
public static class SMJSalesLine_Extension
{

[SysClientCacheDataMethodAttribute(true)]
  public static display container symbolcolor(PurchLine PurchLine)
    {
        ImageReference ImageReference;
        container imagecontainer;
        PurchTable purchTable;
        select  purchTable where purchTable.PurchId == PurchLine.PurchId;
        if(purchTable.PurchStatus==PurchStatus::Invoiced)
            ImageReference=ImageReference::constructForSymbol("GreenCheck");
        else
            ImageReference=ImageReference::constructForSymbol("RedX");
        if(ImageReference)
        {
            imagecontainer=ImageReference.pack();
        }

          return imagecontainer;
    }
}


We want to set the properties of the image control now: the DataSource property will be LogisticsPostalAddress, the “Data Method” property will be our display method.

Extension methods are not visible using the drop down, so you use a special syntax with style ExtensionClassName::DisplayMethod. So in this case it will be
Ex: SMJSalesLine_Extension::symbolcolor


Output


Comments

Popular posts from this blog

SSRS Report using Controller , Contract and RDP classes in D365

Exporting data to Excel through X++ code

COC for Form level method

How to pass the parameter from one form to another in Dynamic365

Multi Select Lookup in SSRS Report in D365