Hi.
I am trying to create an script to send a message when the user select one of the international ship methods on a Sales Order but I am having no luck.
We want to accomplish the following:
When the user selects the international ship method, the script will also look at the item(s) for our custom field "ships individually".
If all the items on the Sales Order have that field check, we don't want to pop the message.
If one of the items on the Sales Order have that field uncheck, we would like to pop our message.
We can't use a work flow because the ship method it's under the shipping tab on the Sales Order.
The following script it is just to pop a message when the user selects one of the international ship methods but even this one it's not working as expected.
/**
* @NApiVersion 2.0
* @NScriptType ClientScript
*/
define(['N/ui/dialog'], function (dialog) {
function fieldChanged(context) {
if (context.fieldId === 'shipmethod') {
var currentRecord = context.currentRecord;
var shipMethod = currentRecord.getValue({
fieldId: 'shipmethod'
});
log.debug({
title: 'Ship Method',
details: shipMethod
});
// List of ship methods to check against
var shipMethodsToCheck = [1043, 21033, 11416, 16335, 1030, 11418, 1039, 11674];
if (shipMethodsToCheck.indexOf(shipMethod) !== -1) {
dialog.alert({
title: 'Shipping Notice',
message: 'HOLA- You have change the message...'
});
}
}
}
return {
fieldChanged: fieldChanged
};
});