16 March 2023

JSON file format to generate for outbound in Dynamics 365 F&O

 

JSON file format to generate for outbound:

Class: formJsonSerializer

Contract class: pickListHeaderContract , need to pass all required values to contract class.


Str  sJSONHeader = FormJsonSerializer::serializeClass(pickListHeaderContract);

13 February 2023

Form control value versioning view Manager and make bold the modified value in Form Control in D365 FO

 x++ code  to set bold of field value  based on the modification in D365FO Form control

Form : PurchVendorPortalResponses

 private void registerForChangeTracking()

    {

        viewManager = VersioningDocumentViewManager::construct();

        viewManager.registerDataContainerForDataSource(PurchaseOrderResponseHeader_DS,

            VersioningDocumentViewDataContainer::constructFromDataSource(

                PurchaseOrderResponseHeader_DS,

                [fieldStr(PurchaseOrderResponseHeaderAllVersions, PurchTableVersion)],

                fieldStr(PurchaseOrderResponseHeaderAllVersions, VersionDateTime),

                new PurchaseOrderResponseHeaderMapper()));

        viewManager.registerDataContainerForDataSource(PurchaseOrderResponseLine_DS,

            VersioningDocumentViewDataContainer::constructFromDataSource(

                PurchaseOrderResponseLine_DS,

                [fieldStr(PurchaseOrderResponseLineAllVersions, PurchTableVersion),

                 fieldStr(PurchaseOrderResponseLineAllVersions, PurchaseOrderResponseLine)],

                fieldStr(PurchaseOrderResponseLineAllVersions, VersionDateTime),

                new PurchaseOrderResponseLineMapper()));

        viewManager.registerControlForTracking(PurchaseOrderResponseHeader_DlvTerm);

        viewManager.registerControlForTracking(PurchaseOrderResponseHeader_DlvMode);

        viewManager.registerControlForTracking(PurchaseOrderResponseHeader_VendorRef);

        viewManager.registerControlForTracking(PurchaseOrderResponseLine_PurchQty);

        viewManager.registerControlForTracking(PurchaseOrderResponseLine_ConfirmedDlv);

        viewManager.registerControlForTracking(PurchaseOrderResponseLine_ExternalItemId);

        viewManager.registerControlForTracking(PurchaseOrderResponseLine_Name);

    }

=====

Extension to add extra feild.

/// <summary>

/// 

/// </summary>

[ExtensionOf(formstr(PurchVendorPortalResponses))]

final class TestPurchVendorPortalResponses_Extension

{

    /// <summary>

    /// 

    /// </summary>

    public void init()

    {

        next init();

        viewManager.registerControlForTracking(PurchaseOrderResponseLine_PurchPrice);

    }

}

====

Similarly:

Form: PurchVendorPortalAllResponse

Method: registerForChangeTracking()

Extenion to add new control for tracking and bold:

[ExtensionOf(formstr(PurchVendorPortalAllResponse))]

final class TestPurchVendorPortalAllResponse_Extension

{

    public void init()

    {

        next init();

        VersioningDocumentViewManager viewManager = this.getViewManager();

        viewManager.registerControlForTracking(PurchaseOrderResponseLineAllVersions_PurchPrice);

    }

}

23 October 2022

Modify Email Subject for a report in D365 F&O from x++

 

Modify Email Subject for a report in D365 F&O from x++



public void printReport()
    {
        if (reportContract.parmRdpName() == "ProjInvoiceDP") //Dp classs name
        {
            ProjInvoiceContract contract = reportContract.parmRdpContract() as PSAProjInvoiceContract;         
          
            ProjInvoiceJour       invoiceJournal;
             
            select firstonly * from invoiceJournal where invoiceJournal.RecId == contract.parmProjInvoiceJourRecId();           //Get the which field we need to add in subjcet 
 
            printSettings.emailSubject(strFmt(" %1", invoiceJournal.ProjInvoiceId));
            printSettings.fileFormat(SRSReportFileFormat::PDF);
            printSettings.fileName(strFmt("SAProjInvoiceModern.Report")); //attached file output  
        }
 
        next printReport();
    }

10 September 2022

Get object of Caller Form In Extension Class/ element to use in init extenion in D365Fo / Is it possible to get element.args() from an extended method in D365FO

Hi, in form method COC we can directly use the this instead of element.Even we can use the control names as it is.
Below is the example.

[ExtensionOf(formstr(ReqTransPO))]
final class ReqTransPOForm_Extension
{
    public void init()
    {
        next init();
        if (this.args().menuItemName() == "ReqPOGridView")
        {
            Contol.visible(false); // form control making visible false
            Control.visible(false);// form control making visible false
        }
    }

}

Get the selected records in the form grid in class 

class ClassParmData

{

         CustTable custTable;// table buffer declaration

}

public static void main(Args args)

{

         ClassParmData parmData;

         Table1 table1;

         FormDataSource fds;

 

         if(args.record().TableId == tablenum(CustTable))

         {

                  custTable = args.record(); // assigning the selected record

         }

 

         fds = custTable.dataSource();// getting the datasource

 

         parmData= new ClassParmData(fds); //passing the form datasource to New() method

}

 

void new(FormDataSource fdst) // receving the datasource to fdst-FormDataSource

{

         // 1st optoin to do this

         MultiSelectionHelper helper = MultiSelectionHelper::construct();

        helper.parmDatasource(fdst);

         custTable = helper.getFirst();

         while (custTable.RecId != 0)

        {

                  custTable = helper.getNext();

         }

         // second way

         for(custTable = fdst.getFirst(true); custTable; custTable = fdst.getNext()) // fdst.getFirst(True) to select marked records

         {

                  info(strfmt(custTable.Field1));

         }

         //if you are updating some records in the form write the below line to refresh the data in form.

         //fdst.research();

}

 

void parmFormDataSource(formDataSource fdst)

{

         for(custTable = fdst.getFirst(true); custTable; custTable = fdst.getNext()) // fdst.getFirst(True) to select marked records

         {

         info(strfmt(custTable.Field1));

         }

         //if you are updating some records in the form write the below line to refresh the data in form.

         //fdst.research();

}

Service class to get the selected record and deleted matching records and refresh the form data source in D365 F&O

 [DataContractAttribute] class ABCUserProfilesBulkDeleteContract {         UserId userId;     [DataMemberAttribute('UserId')]     pu...