Version: eXtendSanMar 1.0.5.5 and above
Audience: Administrator, Developer

eXtendSanMar enables configurable mapping for SanMar's invoice data based on your preferences. If you want the NetSuite vendor bill created from SanMar's invoice data to hold the invoice date instead of the date created in NetSuite, use the following approach.

To avoid NetSuite's default transaction dating behavior, create a new eXtendTech Field Mapping.

1. Go to eXtendTech eXtendSanMar Field Mapping List New.

2. Configure the eXtendTech Field Mapping record as follows:

  1. Name:
    sanmar_ns_vendor_bill_invoice_date

  2. Integration Name:
    sanmar_ns_vendor_bill

  3. Mapping List:
    functional

  4. Output Field:
    trandate

  5. Transform Function:
    getInvoiceDate

  6. Output Data Type:
    date
Image Placeholder

After the mapping is in place, new NetSuite vendor bills generated using eXtendSanMar will use the invoice date from SanMar's invoice response as the transaction date on your NetSuite vendor bill.

Note: Please confirm that the suite_sanmar_transformers.js file contains the getInvoiceDate() function below for the mapping to work. If the file does not contain the getInvoiceDate() function, add it as a new function in your suite_sanmar_transform.js file.

/**
 * @param {Object} args
 * @param {Object} args.sourceNativeRecord
 */
function getInvoiceDate(args) {
  var sourceNativeRecord = args.sourceNativeRecord;
  var invoiceDate = sourceNativeRecord.Invoice__Header__InvoiceDate || '';

  if (!invoiceDate) {
    return;
  }

  // Invoice Date receive from SanMar as YYYY-MM-DD format
  log.debug({ title: 'invoiceDate', details: invoiceDate });

  var invoiceDateObject = invoiceDate.split('-');

  if (invoiceDateObject.length !== 3) {
    return;
  }

  var year = invoiceDateObject[0];
  var month = invoiceDateObject[1];
  var date = invoiceDateObject[2];

  invoiceDate = month + '/' + date + '/' + year;

  var parsedDateStringAsRawDateObject = format.parse({
    value: invoiceDate,
    type: format.Type.DATE
  });

  var formattedDateString = format.format({
    value: parsedDateStringAsRawDateObject,
    type: format.Type.DATE
  });

  var dataObject = new Date(formattedDateString);
  log.debug({
    title: 'formattedDateString',
    details: {
      'formattedDateString': formattedDateString,
      'typeof': typeof formattedDateString,
      'dataObject': dataObject,
      'typeof_dataObject': typeof dataObject
    }
  });

  return { value: dataObject };
}