Hi all, I'm getting an error `Invalid orderstatus ...
# suitescript
k
Hi all, I'm getting an error
Invalid orderstatus reference key [object Object]
when I attempt to utilize a workflow action script to change the order status from "pending approval" to "pending receipt" on a Return Authorization. Any idea what could be the reason for this?
Copy code
define(['N/record','N/search','N/ui/dialog', 'N/log'], function (record, search, dialog, log) {

    
    function onAction(scriptContext) {
        var currentRecord = scriptContext.newRecord;
      
      var intid = currentRecord.id;
        log.debug({
        title: 'Internal ID',
        details: intid
        });
        
        var Status = currentRecord.setValue({
            fieldId: 'orderstatus',
          	value: 'B'
        });
        log.debug({
            title: 'Order Status', 
            details: Status
        });
        
        dialog.alert({
            title: 'Return Aurhotization',
            message: 'You are viewing ' + currentRecord
        });

      	return Status
    }
 
    return {
        onAction: onAction
    }
    
});
s
this works for me in the console, so nothing appears to be too wrong
Copy code
let rec = record.load({type: record.Type.RETURN_AUTHORIZATION, id: 79848, isDynamic: true});
rec.setValue({fieldId: 'orderstatus', value: 'B'});
rec.save();
the error kinda looks like something else is occuring when you are doing this action... I would certainly remove the dialog.alert() as well as it is providing nothing of use
s
you could wrapping the setting of the order status in a try {} ctach {} and then JSON.stringify the error so you know what it means by [object Object]
s
I'd also just simplify the entire script to
context.newRecord.setValue({fieldId: 'orderstatus', value: 'B'})
, nothing else is needed there