Inbound E-Document Templates in JSON Format
An inbound e-document template defines how data from an incoming XML file is mapped into fields on NetSuite vendor bill or vendor credit records.
Templates are authored in JSON format. A sample JSON template is included with the SuiteApp and is available for download in the NetSuite file cabinet. You can use or customize this sample template to convert XML inbound e-documents into vendor bills or vendor credits.
You can view the number of inbound e-documents awaiting conversion on the E-Documents portlet on your NetSuite dashboard. To add the E-Documents portlet to your dashboard, see Displaying the E-Documents Portlet on the Home Page.
You can use or customize the following sample JSON template that contains the mapping to basic vendor bill or bill credit information:
<#ftl ns_prefixes={"A":"http://www.w3.org/2001/XMLSchema-instance", "D":"urn:oasis:names:specification:ubl:schema:xsd:Invoice-2", "cac":"urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2", "cbc":"urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"}>
{
"tranid": "${XML["D:Invoice"]["cbc:ID"]}",
"trandate": "${CUSTOM["trandate"]}",
<#if CUSTOM["duedate"]??>
"duedate": "${CUSTOM["duedate"]}",
</#if>
"memo": "${XML["D:Invoice"]["cbc:Note"]}",
<#if CUSTOM["currency"]?has_content>
"currency": "${CUSTOM["currency"]}",
</#if>
"custbody_ste_use_tax":"T",
"item": [
<#assign index=0>
<#list XML["D:Invoice"]["cac:InvoiceLine"] as item>
{
"vendorname": "${item["cac:Item"]["cbc:Name"]}",
"vendorcode": "${item["cac:Item"]["cbc:Name"]}",
"quantity": "${item["cbc:InvoicedQuantity"]}",
"description": "${item["cac:Item"]["cbc:Description"]}",
"rate": "${item["cac:Price"]["cbc:PriceAmount"]}",
"amount":"${item["cbc:LineExtensionAmount"]}",
<#assign index++>
}<#if item_has_next>,</#if>
</#list>
],
"expense": [
<#assign hadPrevious=false>
<#if CUSTOM["isSuiteTax"]?lower_case != "true">
<#list XML["D:Invoice"]["cac:TaxTotal"]["cac:TaxSubtotal"] as exp>
<#if hadPrevious>,</#if>
{
"memo": "${exp['cac:TaxCategory']['cbc:ID']}:TAXES",
"amount": "${exp['cbc:TaxAmount']}"
}
<#assign hadPrevious=true>
</#list>
</#if>
<#list XML["D:Invoice"]["cac:AllowanceCharge"] as ac>
<#if (ac['cbc:ChargeIndicator']?lower_case == 'true') && (ac['cbc:AllowanceChargeReason']?upper_case?contains("SHIPPING"))>
<#if hadPrevious>,</#if>
{
"memo": "SHIPPING",
"amount": "${ac['cbc:Amount']}"
}
<#assign hadPrevious=true>
</#if>
<#if (ac['cbc:ChargeIndicator']?lower_case == 'true') && (ac['cbc:AllowanceChargeReason']?upper_case?contains("HANDLING"))>
<#if hadPrevious>,</#if>
{
"memo": "HANDLING",
"amount": "${ac['cbc:Amount']}"
}
<#assign hadPrevious=true>
</#if>
<#if (ac['cbc:ChargeIndicator']?string?lower_case == "false") && (ac['cbc:AllowanceChargeReason']?upper_case?contains("DISCOUNT"))>
<#if hadPrevious>,</#if>
{
"memo": "DISCOUNT",
"amount": "-${ac['cbc:Amount']}"
}
<#assign hadPrevious=true>
</#if>
</#list>
]
}
The JSON inbound template contains the following key names and mapping to basic bill information:
|
Key Name |
Description |
|---|---|
|
tranid |
Reference number for the vendor bill. It is a required key name. |
|
trandate |
Date of the transaction. |
|
currency |
Transaction currency. |
|
memo |
Memo or note for the vendor bill. |
|
item |
Item on the vendor bill. It is a required key name. There are five related key names under item:
Note:
Based on the Multiple Vendor feature setting, either vendorcode or vendorname must be used under item:
|
|
expense |
Expense on the vendor bill. There are two related key names under expense:
|
The key names are used for mapping fields in the vendor bill record. Each key name maps to a corresponding field ID of the vendor bill record and extracts its value from the received XML. The value of the key name will be entered in the corresponding field of the vendor bill record.