Wednesday, 31 May 2017

AIF Outbound Message - Replace data / inserting data into the XML message

In this blog we will lean how to replace the data in the Outbound XML ..


For this we need to override the "processingRecod()" method.

Lets see how it will work.

First we will look at the method
public void processingRecord(Common common)
{
 
    super(common);
}

so you can see that, it passes the common record.

First check if the common record, exist and is of your Table to be modified and update the buffer and assign back the data to common.
In the below eg. I am modifying the VendAccount to CustAccount.

public void processingRecord(Common common)
{
    PurchTable  lpurchTable;
    MK_IntercompanySOParam     parmSO = AMS_IntercompanySOParam::find();
    if (common)
    {
        if (common.TableId == lpurchTable.TableId)
        {
            lpurchTable = common.data();
            lpurchTable.OrderAccount = parmSO.CustAccount;
            common.data(lpurchTable);
           
        }
       
    }
    super(common);
}

After this, we need generate a incremental CIL.

-------------------------------------------------------------------------------------------------------------------------
Alternatively, we can use the outbound pipeline by adding this code in the execute method of the pipeline:
public void execute(AifPipelineComponentRecId componentRecId, AifMessage message, AifPipelineParms parms)
{
    XmlDocument xmlDoc = new XmlDocument();
    XmlNode xmlNode;
    XmlNodeList xmlNodeList;
    XmlElement xmlElement;
    ;

    xmlDoc = XmlDocument::newXml(message.getXml());
    xmlNodeList = xmlDoc.getElementsByTagName("SalesTable");

    // Obtain the first xmlNode.
    xmlNode = xmlNodeList.nextNode();
    xmlElement = xmlNode.getNamedElement("CustAccount");
    xmlElement.text("4005"); // If you use the sample CreateSalesOrder.xml file, the value should be 4000 instead of 4005.
    message.setXml(xmlDoc.xml());
}

Mallik 

Import and Export file from BLOB storage Account(Azure) in D365 F&O using X++

  Import and Export file from BLOB storage Account in D365 F&O using X++ Import: /// <summary> /// MKInventQualityOrderLineService...