Monday, 2 September 2019

Add image symbol based on condition in D365 using x++


List of symbols and usage: https://mbs.microsoft.com/files/public/CS/AX/DynamicsSymbolFont_Update8.pdf

    public display container domhasCustNotes()
    {
        DocuRef             docuRef;
        CustTable           custTable;
        ImageReference      imageReference;
        container           imagecontainer;

        select firstonly RecId from custTable
            where custTable.AccountNum == this.CustAccount;

        select firstonly RecId from docuRef
            where docuRef.RefRecId == custTable.RecId
                && docuRef.USMFSalesOrderEntry == NoYes::Yes;

        if (docuRef.RecId)
        {
            imageReference  = ImageReference::constructForSymbol('RedDiamond');
        }
        if (imageReference)
        {
            imagecontainer  = imageReference.pack();
        }
       
        return imagecontainer;
    }

Standard reference
Ex : PurchReqTable form
Method PurchReqLineDS

public display container workflowIcon(PurchReqLine _line)
        {
            ImageReference imgRef;

            workflowIconObservableLink.observe();

            if (Workflow::findWorkItemsForCurrentUser(_line).elements())
            {
                imgRef = ImageReference::constructForSymbol(ImageReferenceSymbol::Workflow);
            }
            else
            {
                imgRef = ImageReference::constructForSymbol('');
            }

            return imgRef.pack();
        }