what does this mean and how to fix? `name":"INVAL...
# suitescript
j
what does this mean and how to fix?
name":"INVALID_FLD_VALUE","message":"Value 0.0 outside of valid min/max range for field quantity",
c
It depends on what you're trying to do, but quantity has to be >0 on new transactions lines
j
right, but the number I'm trying to push is 1
c
Share your code then šŸ™‚
j
Copy code
/**
 * @NApiVersion 2.x
 * @NScriptType UserEventScript
 * @NModuleScope SameAccount
 */
 define(['N/record', 'N/search'],
 /**
  * @param {record} record
  * @param {search} search
  */
 function(record, search) {
    

     function beforeLoad(scriptContext) {

         var recType = record.load({type: record.Type.ITEM_FULFILLMENT, id: 5679548, isDynamic:true});

         var count = recType.getLineCount({sublistId:'item'});


         for ( var i=0; i < count ; i++)
         {
             var selectLine = recType.selectLine({sublistId:'item',line:i});
             var id = recType.getCurrentSublistValue({sublistId:'item',fieldId:'id'});
             var fulfillmentQty = recType.getCurrentSublistValue({sublistId:'item',fieldId:'quantity'});
             var nsdrReturn  = recType.getCurrentSublistValue({sublistId:'item',fieldId:'custcol_delivery_routing_return_qty'});
           	 var adjQty = fulfillmentQty - nsdrReturn;
               log.debug({
                     title: ({title: 'new qty'}),
                     details: adjQty
                 })
 
             log.debug(id + fulfillmentQty + nsdrReturn);
             recType.setCurrentSublistValue({sublistId:'item',fieldId:'quantity',value: adjQty});
             recType.commitLine({sublistId:'item'});
         }
         
         //commit the item record.  The sublist will update
         recType.save();
     }
 
     return {
         beforeLoad: beforeLoad,
     };
     
 });
trying to pass the value from
adjQty
Copy code
recType.setCurrentSublistValue({sublistId:'item',fieldId:'quantity',value: adjQty});
b
My guess that you are setting the wrong line with a wrong value
Hardcode the adjQty to 1
Remove the loop and only set 1 item line
Choose a line that you know can be set to 1 in the ui
j
tried that. I think the field is returning a decimal, based on the error I'm getting. name":"INVALID_FLD_VALUE","message":"Value 0.0 outside of valid min/max range for field quantity",
I tried removing the loop and hitting the line directly but same error came up
I also hard coded to 1 and that does set the value and it works.
but I need a subtraction between 2 columns to happen before setting the value on the qty
b
Do both, set only 1 line and then hardcode the value
Graduate to subtraction qty on that 1 line
Graduate to doing 2 lines
j
so that works -hardcoded to the existing value • subtraction ran and set to 1 Concept is there pretty much
b
the guess is that one of the lines on the item fulfillment does not work with your code
go through each line and do your code on it until you find which
j
I agree
nsdrReturn
is set as a Text value and I just tried this:
ecType.setCurrentSublistValue({sublistId:'item', fieldId:'quantity', value: fulfillmentQty});
This works
ecType.setCurrentSublistValue({sublistId:'item', fieldId:'quantity', value: fulfillmentQty - nsdrReturn});
This errored out with the same decimal error 0.0
b
does the code work on 1 line yet?
or are you moving onto 2?
c
As an aside, does seem like a weird way of dealing with returns
(I know some accountants wouldn't like this)
j
it is part of a POD integration and they want fulfillment qty to update based on returned qty šŸ˜–
I have warned them but they still want it
b
id expect that strategy to fail
šŸ’Æ 1
returning all the items would be deleting the fulfillment
s
@JC I think the only way this can work (and I'm by no means suggesting this approach) You transform the record, and then you remove all the lines and add new ones. And at that time you also add new ones as in "mimic" what the transformation was, then setting quantity to 0 This way at least wouldn't violate the original sales order/fulfillment/invoicing so I'd tend to believe this is more plausible.
Even if you set it to one (quantity of the new item fulfilment line), if you removed all the lines on the transform, I do believe it doesn't count towards the sales order lines, which would make the case still valid. But take it with a grain of salt, we would be in the realm of trying to break the system, and I have no idea the consequences held down the line.