How toDeveloper Guide

Developer Guide

Sana Commerce 8.2
Your provider

Extend the Order Export

If you want to transfer custom fields during the order export, you will need to create a custom order export task. Follow the steps to create a custom order export task:

Create a new class that inherits from the 'Order Export' task.

If the 'Order Export' task is not configured in your project then read this chapter for more information about how to configure the 'Order Export' task. In another case just replace the 'type' attribute with newly created class.

  • If the desired table column exists in the 'Sales Header' table in NAV you should use the following way to override the 'PrepareOrder' method:
    protected override void PrepareOrder(IOrder order)
    {
        base.PrepareOrder(order);
        order["ColumnName"] = "Value";
        order.Fields["ColumnName"].StoreWithEntity = true;
    }

  • If the desired table column does not exist in the 'Sales Header' table in NAV you should use another way to override the 'PrepareOrder' method.
    You can just send data to NAV and handle it there. In this case the 'PrepareOrder' method should look like this:
    protected override void PrepareOrder(IOrder order)
    {
        base.PrepareOrder(order);
        order["CustomFieldName"] = "CustomFieldValue";
    }
    In NAV you can receive this field using the 'GetCustomField' method. It will look like:
    XMLFunctions.GetCustomField(InXml,'CustomFieldName',TRUE);
    where:
    XMLFunctions: an instance of 'SC - XML/System Functions' codeunit;
    InXml: XML request which was send to NAV;
    'CustomFieldName': the name of your custom field;
    TRUE: the parameter which indicates whether this field should be removed after reading.
How toDeveloper Guide