Version: eXtendPS-SE 1.3.6.7 and above
Audience: Administrator, Developer
eXtendPS-SE allows you to send a custom Ship From Address and Ship To Address in the PromoStandards Order Shipment Notification response by using custom SuiteScript functions.
Details regarding the use of these functions are below:
Order Shipment Response (without custom function) Logic
In normal cases, when no custom function is configured, the "Ship To Address" and "Ship From Address" will be sent using the following logic:
Ship From Address Logic:
- If the "Locations" feature is enabled in your NetSuite account and a location is specified on your transaction record, the address of that location will be sent as the "Ship From Address" in the Order Shipment Notification response.
- OneWorld account behavior:
- If the location field on the transaction level is not available, the Order Shipment Notification response will include the shipping address of the transaction's subsidiary.
- If the subsidiary's shipping address is empty, the subsidiary's main address will be used.
- Non-OneWorld account behavior:
- If the location field on the transaction level is not available, the shipping address from Company Information will be used.
- If the shipping address from Company Information is empty, the main address from Company Information will be used.
Ship To Address Logic:
1. The "Shipping To Address" specified on the transaction will be used as ship to address in the Order Shipment Notification response.
Order Shipment Response (with custom function) Logic
If a custom function is configured in your account, the "Ship To Address" and "Ship From Address" will be sent in the Order Shipment Notification response based on the scripted function.
The functions for "Ship To Address" and "Ship From Address" are getOSNShipToAddressData() and getOSNShipFromAddressData().
Note: If your function returns a null value, the Order Shipment Notification response will return a null value.
These functions will be added in the suite_promoapi_invoice_transformers.js file. If there are multiple files in your account with this name, select the one which is in the eXtendTech folder.
ShipFromAddress Hook Function Format
/** * @desc This method will return a custom shipFromAddress for the Shipment service in the below format * @param {Object} args * @prop {Object} args.osnSetupData * @prop {Array} args.searchResults * @prop {String} args.itemFulfillmentId * @prop {String} args.fulfillmentSearchResult * * @returns {Object} * { * address1: 'value', * address2: 'value', * address3: 'value', * address4: 'value', * city: 'value', * region: 'value', * postalCode: 'value', * country: 'value', * }; */ function getOSNShipFromAddressData(args) { var osnSetupData = args.osnSetupData; var searchResults = args.searchResults; var itemFulfillmentId = args.itemFulfillmentId; var fulfillmentSearchResult = args.fulfillmentSearchResult; // log.debug({ title: 'getOSNShipFromAddressData args keys', details: Object.keys(args) }); // return { // "address1": "16 Starline Dr", // "address2": "8 Mile Road", // "city": "Montville", // "region": "NJ", // "postalCode": "07045", // "country": "US" // } }
ShipToAddress Function Format
/** * @desc This function will return a custom shiToAddress for Shipment service * @param {Object} args * @prop {Object} args.osnSetupData * @prop {Array} args.searchResults * @prop {String} args.itemFulfillmentId * @prop {String} args.fulfillmentSearchResult * * @returns {Object} * { * address1: 'value', * address2: 'value', * address3: 'value', * address4: 'value', * city: 'value', * region: 'value', * postalCode: 'value', * country: 'value', * }; */ function getOSNShipToAddressData(args) { var osnSetupData = args.osnSetupData; var searchResults = args.searchResults; var itemFulfillmentId = args.itemFulfillmentId; var fulfillmentSearchResult = args.fulfillmentSearchResult; // log.debug({ title: 'getOSNShipToAddressData args keys', details: Object.keys(args) }); // return { // address1: searchResults[0].getValue({ name: 'shipaddress1' }) || undefined, // address2: searchResults[0].getValue({ name: 'shipaddress2' }) || undefined, // address3: searchResults[0].getValue({ name: 'shipaddress3' }) || undefined, // city: searchResults[0].getValue({ name: 'shipcity' }) || undefined, // region: searchResults[0].getValue({ name: 'shipstate' }) || undefined, // postalCode: searchResults[0].getValue({ name: 'shipzip' }) || undefined, // country: searchResults[0].getValue({ name: 'shipcountry' }) || undefined // }; // return { // address1: '16 Starline Dr', // address2: '8 Mile Road', // city: 'Montville', // region: 'NJ', // postalCode: '07045', // country: 'US' // } }