Creating E-Document Transaction Response Template
In an e-document transaction response, the template maps the data in a NetSuite transaction record, which will populate the elements in the XML or JSON file. This file is generated and sent to the customers or vendors.
You can use FreeMarker to create the template content for transaction response e-documents. For more information about scriptable templates and FreeMarker, see the following topics:
To create an e-document transaction response template:
The e-document transaction response template is automatically selected based on the subsidiary and transaction response for which it is defined.
-
Go to Setup > E-Documents > E-Document Transaction Response Templates > New.
-
In the Name field, enter a name for the template.
-
(Optional) In the Description field, enter a text that describes this template.
-
(Optional) From the Custom Data Source Plugin Implementation list, select a plug-in implementation.
The selected plug-in enables you to include a custom data source in the template. After which, you can add more field values to the transaction response e-documents that will be generated using the template.
-
From the Transaction Type list, select one or more incoming transaction types for which this template will be used. To select multiple transaction types, press and hold the ctrl key when selecting the transaction types.
-
(For an outbound template) From the Subsidiary list, select the subsidiaries that you want to associate with this template. To select multiple subsidiaries, press and hold the ctrl key when selecting the subsidiaries.
-
In the Template for Outbound Transaction Response field, enter the XML content of the outbound e-document transaction response template.
-
Click Save.
You can only define one e-document transaction response template for one subsidiary and transaction type.
Setting Avalara Mandate and Data version on Transaction Response
Avalara mandate and Data format version for a Transaction response can be sourced from custom data source (CDS), which will be populated on transaction response record on successful generation of transaction response content.
Return an activated mandate from CDS.
Both mandate and data format version will be used while sending transaction response content to Avalara. The following code is a sample custom plugin implementation for Avalara transaction response custom data source:
/**
* @NApiVersion 2.x
* @NScriptType plugintypeimpl
* @NModuleScope Public
*/
define(["N/render"], function (nsrender) {
/**
* inject - This function will provide the custom data source during the transaction response generation process
* @param {Object} params
* @param {String} params.transactionId (only present if transaction is linked to Transaction Response record)
* @param {Object} params.transactionRecord (only present if transaction is linked to Transaction Response record)
* @param {Object} params.transactionResponseRecId
*
* @returns {Object}
*/
function inject(params) {
try {
/**
* implement custom logic for transaction response content generation
*/
var customObj = {
mandate: "BE-B2B-PEPPOL", // specify an activated mandate
dataVersion: "2.3", // specify the required data format version (default 2.1)
};
return {
customDataSources: [
{
format: nsrender.DataSource.OBJECT,
alias: "custom",
data: customObj,
},
],
};
} catch (e) {
log.error("CDS error:", e);
return {
result: {
success: false,
eiAuditTrailMsg: e.message, // custom message which will be populated on Transaction response record under "Error Details" tab
},
};
}
}
return {
inject: inject,
};
});