I have been trying for a number of days to deploy a validate line script to Sales Orders to check line level fields.
Is there something peculiar / specific to validate line scripts that I need to be aware of. I am not particularly experienced in scripting, but I have successfully deployed other client and user event scripts.
I based my script on this article:
Client Script to Check Item Type before Adding to the Item Sublist (custhelp.com)
And simplified it to this:
/**
*@NApiVersion 2.x
*@NScriptType ClientScript
*/
define(['N/currentRecord'], function (currentRecord) {
// /**
// * @param {ClientScriptContext.validateLine} context
// */
function validateLine(context) {
var itemPORate = currentRecord.getCurrentSublistValue({
sublistId: 'item',
fieldId: 'porate'
});
if (itemPORate == 0) {
var itemCost = currentRecord.getCurrentSublistValue({
sublistId: 'item',
fieldId: 'custcol_cust_costprice'
});
context.currentRecord.setValue({
fieldId: 'porate',
value: '9.99'
});
}
return true;
}
return {
validateLine: validateLine
};
});
I have tried other variations including one based on this:
javascript - How can I use SuiteScript 2.0 to validate Transfer Order line quantity? Script does not seem to be initializing - Stack Overflow
As far as I can tell I don't think the script is running at all. I've added in alert lines, and attempted to configure logging, but I cannot see any evidence of the script running.
I have even tried putting in a clearly invalid line in the script in the hope of triggering an error, so I am fairly sure it is not running.
I've checked the browser plugin and it appears the script is deployed:
The script appears to have been recognised as a Validate Line script:
And has been deployed to Sales Orders:
Is there something I'm missing? Or are there peculiarities with validateline scripts that I need to be aware of?