Ryan
03/09/2023, 5:51 PM/**
*@NApiVersion 2.1
*@NScriptType UserEventScript
*/
define([],
function() {
function beforeSubmit(context){
log.debug({
title: 'Set WO Checkbox',
details:'script started'
});
if(context.type = context.UserEventType.CREATE){
var salesOrder = context.newRecord;
var itemSublistSize = salesOrder.getLineCount({
sublistId: 'item'
});
var CustomerType = salesOrder.getValue({
fieldId:'custbody_sc_cust_category'
});
if (CustomerType != 'Customer' || 'International Customer'){
for (x = 0; x <= itemSublistSize -1; x++) {
salesOrder.setSublistValue({
sublistId:'item',
fieldId: 'createwo',
line:x,
value:true
});
}
log.debut({
title:'Create Work Orders',
details:'Script Done'
});
}
}
}
return{
beforeSubmit: beforeSubmit
};
});
Anthony OConnor
03/09/2023, 5:58 PM=
is an assignment.. "make this equal to"
for comparisons you need ==
"is this equal to"Anthony OConnor
03/09/2023, 6:00 PM||
you need to fully write out both of them...
this should read
if (CustomerType != 'Customer' || CustomerType != 'International Customer'){
... but even then its gonna be wrong doing ORs and NOTs gets messy so generally avoid that....Anthony OConnor
03/09/2023, 6:05 PMvar CustomerType = salesOrder.getValue({fieldId:'custbody_sc_cust_category'});
var validCustomerType = true;
if (CustomerType == 'Customer' || CustomerType == 'International Customer'){ validCustomerType = false; })
if (validCustomerType){...
...
}
Anthony OConnor
03/09/2023, 6:07 PMAnthony OConnor
03/09/2023, 6:08 PMx < itemSublistSize;
... remove the equals and remove the -1, just simplerAnthony OConnor
03/09/2023, 6:09 PMRyan
03/09/2023, 6:11 PMAnthony OConnor
03/09/2023, 6:16 PMRyan
03/09/2023, 6:24 PMAnthony OConnor
03/09/2023, 6:43 PMAnthony OConnor
03/09/2023, 6:56 PMRyan
03/09/2023, 7:05 PMbattk
03/09/2023, 7:08 PMbattk
03/09/2023, 7:08 PMif (CustomerType != 'Customer' || 'International Customer')
battk
03/09/2023, 7:09 PMbattk
03/09/2023, 7:09 PMbattk
03/09/2023, 7:09 PMbattk
03/09/2023, 7:10 PMAnthony OConnor
03/09/2023, 7:10 PMRyan
03/09/2023, 7:10 PM/**
*@NApiVersion 2.1
*@NScriptType UserEventScript
*/
define([],
function() {
function beforeSubmit(context){
log.debug({
title: 'Set WO Checkbox',
details:'script started'
});
if(context.type == context.UserEventType.CREATE){
var salesOrder = context.newRecord;
var itemSublistSize = salesOrder.getLineCount({
sublistId: 'item'
});
var CustomerType = salesOrder.getValue({
fieldId:'custbody_sc_cust_category'
});
var validCustomerType = true;
if(CustomerType == 'Customer' || CustomerType == 'International Customer'){
validCustomerType = false;
}
if (validCustomerType){
for (x = 0; x < itemSublistSize; x++) {
salesOrder.setSublistValue({
sublistId:'item',
fieldId: 'createwo',
line:x,
value:true
});
}
}
}
}
return{
beforeSubmit: beforeSubmit
}
});
battk
03/09/2023, 7:15 PMbattk
03/09/2023, 7:15 PMbattk
03/09/2023, 7:15 PMAnthony OConnor
03/09/2023, 7:17 PMRyan
03/09/2023, 7:18 PMCD
03/10/2023, 9:49 AMbeforeSubmit
implicitly return true
or do you have to actually write it? Or does it not matter?Ryan
03/10/2023, 7:28 PMAnthony OConnor
03/10/2023, 8:45 PMAnthony OConnor
03/10/2023, 8:45 PM