We are testing the new 'Payment Instruments' feature in NetSuite with our new SuiteCommerce Advanced site.
In the NetSuite UI there is a 'Payment Operation' field which I believe is a native NetSuite field implemented as part of the Payment Instruments feature.
When creating a Sales Order this can be set to Authorization or Sale
Ideally we want this set to Sale to process the Card Payment at the time of order. It doesn't appear to be possible to access this field using workflow, but I have successfully created a User Event script that will update this 'before submit' to set it to Sale.
*@NScriptType UserEventScript
*/
// Load two standard modules.
define ( ['N/record','N/log'] ,
function(record) {
function myBeforeSubmit(context) {
if (context.type !== context.UserEventType.CREATE)
return;
newRecord.setValue({
fieldId: 'paymentoperation',
value: 'SALE'
});
}
// Add the return statement that identifies the entry point funtions.
return {
beforeSubmit: myBeforeSubmit
};
});
This works well on Sales Orders created in the UI.
However, if I enable this script for the WebStore context, it gives an error saying the value for that field is invalid:
I can't understand why that value is valid in the UI but invalid in SCA?
Can anyone suggest any possible solutions to this?