How toDeveloper Guide

Developer Guide

Sana Commerce 9.0
Your connector

Get Custom Data with Product Not from Item Table

This article is targeted at Microsoft Dynamics NAV developers and provides information on how to return custom item data from the related table in NAV.

For example, you need to retrieve the custom field 'Comments' from Microsoft Dynamics NAV.

You have to extend the XML containing product information which should be returned from Microsoft Dynamics NAV. To do this, add the line of code in the following format to the 'CreateProductXML' function which is in the '11123318 SC - Catalog Helper' codeunit.

ResultNodeBuff.AddFieldElement('<FieldName>','<FieldValue>');

Example:

ResultNodeBuff.AddFieldElement('Comments','Comments');

To use the customer item data that is returned from Microsoft Dynamics NAV to the Sana Commerce framework in the Sana Commerce SDK the field can be accessed through the 'Fields' collection by key. You can use the following code to get the field value:

var comments = product["Comments"];

You can also save the value in another place by overriding the 'SaveProduct' product function of the class inherited from the 'ProductImportTask' class and adding the code to the save value.

How toDeveloper Guide