Knowledge BaseNAV Developer Guide

NAV Developer Guide

Sana Commerce 9.2
Your connector

Sana Commerce Customization Scenarios

Below you can find the description of two common customization scenarios of the Sana Commerce framework:

  • Adding custom fields to the entities.
  • Adding new functions into the Sana Commerce framework.

Adding custom fields to the entities

This is the most common customization required by partners and customers. Depending on the specific customer the Microsoft Dynamics NAV objects can contain custom fields, which should be also processed by Sana Commerce. All entities are returned from Microsoft Dynamics NAV as a set of the field-value elements.

Example:

ResultNodeBuff.AddFieldElement('Id',Salesperson.Code);
ResultNodeBuff.AddFieldElement('Name',Salesperson.Name);
ResultNodeBuff.AddFieldElement('Email',Salesperson."E-Mail");
ResultNodeBuff.AddFieldElement('PhoneNo',Salesperson."Phone No.");
ResultNodeBuff.AddFieldElement('JobTitle',Salesperson."Job Title");

To extend it with the extra filed, you need to add a new line in the following format:

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

Adding new functions to the Sana Commerce Framework

At first, decide where to add the new function. It can be added to the existing codeunits or to the new codeunit. See the list of codeunits in the "Microsoft Dynamics NAV Changes" document.

The new function must have two parameters: InXMLBuff and OutXMLBuff with the DataType - Record: SC - XML Buffer (dotNET).

Register the function in the "OnRun" trigger of the codeunit.

Example:

Codeunit "SC - Settings Functions"

OnRun(VAR Rec : Record "SC - Operation")
Context.GetRequestBuff(RequestBuff);
Context.GetResponseBuff(ResponseBuff);
Context.GetParams(Params);
CASE Code OF
  UPPERCASE('GetCountries') : GetCountries(RequestBuff,ResponseBuff);
  // Your custom function, START
  UPPERCASE('YourFunctionName') : YourFunctionName(RequestBuff,ResponseBuff);
  // Your custom function, END
END;
Context.SetParams(Params);

When the function is created and registered in the "OnRun" trigger, you need to register it in the "SC - Operations" table in the following format:

Enabled Operation Name Website ID Codeunit ID Codeunit Name Internal Function 
Yes <YourFunctionName> <Your Website ID> <Your Codeunit ID> <Your Codeunit Name> No

In Microsoft Dynamics NAV click: Departments > Webshop > Administration > Setup. On the Sana Commerce Setup page, click Operations.

At the Sana Commerce side, you need to extend the eBusiness connector, and create a function in it which will generate the XML request and parse the XML response.

Knowledge BaseNAV Developer Guide