Hello everyone, I have a RESTlet script that needs...
# suitescript
k
Hello everyone, I have a RESTlet script that needs to be stopped if a certain condition is met. For example, the following will continue to execute the script for SO00001 even though its checkbox field is true. Please let me know what I should be looking over.
Copy code
var accessoryPO = purchaseOrderRec.getValue({
    fieldId: 'custbody_accessory_po'
});

// Prints true for SO00001
// log.debug('accessoryPO', accessoryPO);

// Skip Accessory POs
if (accessoryPO == 'true') {
    return false; 
};
you specifically are being affected by step 4
k
Thank you! I fixed by comparing true to true, instead of true to 'true'.
b
you dont usually want to compare a boolean to another boolean
for example
Copy code
if (accessoryPO == true) {
    return false; 
};
is more concisely written as
Copy code
if (accessoryPO) {
    return false; 
};
after that, boolean naming conventions like using the is or has prefix make more sense
Copy code
if (isAccessoryPO) {
    return false; 
};
2