Hi, got error when add discount item with custom p...
# suitescript
g
Hi, got error when add discount item with custom price level,{"type":"error.SuiteScriptError","name":"*INVALID_FLD_VALUE*","message":"*You have entered an Invalid Field Value -11.99% for the following field: porate*", Does anyone know what to do. I tried rate field too, get same error. thank you
b
what does the code look like
g
saleOrderRecord.selectNewLine({                             sublistId: 'item'                         });                         saleOrderRecord.setCurrentSublistValue({                             sublistId: 'item'                             , fieldId: 'item'                             , value: 32667                         });                         saleOrderRecord.setCurrentSublistValue({                             sublistId: 'item'                             , fieldId: 'price'                             , value: -1                         });                         saleOrderRecord.setCurrentSublistValue({                             sublistId: 'item'                             , fieldId: 'porate'                             , value: '-11.99%'                         });                         saleOrderRecord.commitLine({                             sublistId: 'item'                         });
b
and you probably want the rate column
g
ok, I will try and update with you later, thanks
@battk not working, got new error {"type":"error.SuiteScriptError","name":"USER_ERROR","message":"Please enter a value for amount." tried on both rate and porate field
b
and the code?
g
saleOrderRecord.selectNewLine({                             sublistId: 'item'                         });                         saleOrderRecord.setCurrentSublistValue({                             sublistId: 'item'                             , fieldId: 'item'                             , value: 32667                         });                         saleOrderRecord.setCurrentSublistValue({                             sublistId: 'item'                             , fieldId: 'price'                             , value: -1                         });                         saleOrderRecord.setCurrentSublistText({                             sublistId: 'item'                             , fieldId: 'porate'                             , value: '-11.9%'                         });                         saleOrderRecord.commitLine({                             sublistId: 'item'                         });
b
make both the changes i recommended
and read the doc i listed earlier to see the differences in setCurrentSublistText and setCurrentSublistValue
they dont use the same parameters
g
wow, didn't realise that. my bad
now the error is back to where I was at beginning
Copy code
saleOrderRecord.selectNewLine({
                            sublistId: 'item'
                        });

                        saleOrderRecord.setCurrentSublistValue({
                            sublistId: 'item'
                            , fieldId: 'item'
                            , value: 32667 // 15560
                        });

                        saleOrderRecord.setCurrentSublistValue({
                            sublistId: 'item'
                            , fieldId: 'price'
                            // , value: 45 //COTD
                            , value: -1
                        });

                        // important use instead of 'rate'
                        saleOrderRecord.setCurrentSublistText({
                            sublistId: 'item'
                            , fieldId: 'porate'
                            , text: '-11.9%'
                        });

                        saleOrderRecord.commitLine({
                            sublistId: 'item'
                        });
"type":"error.SuiteScriptError","name":"INVALID_FLD_VALUE","message":"You have entered an Invalid Field Value -11.99% for the following field: porate",
tried to both porate and rate fields
b
and the error and code for rate?
g
"type":"error.SuiteScriptError","name":"INVALID_FLD_VALUE","message":"You have entered an Invalid Field Value -11.99% for the following field: porate",
Copy code
saleOrderRecord.selectNewLine({
                            sublistId: 'item'
                        });

                        saleOrderRecord.setCurrentSublistValue({
                            sublistId: 'item'
                            , fieldId: 'item'
                            , value: 32667 // 15560
                        });

                        saleOrderRecord.setCurrentSublistValue({
                            sublistId: 'item'
                            , fieldId: 'price'
                            // , value: 45 //COTD
                            , value: -1
                        });

                        // important use instead of 'rate'
                        saleOrderRecord.setCurrentSublistText({
                            sublistId: 'item'
                            , fieldId: 'porate'
                            , text: '-11.9%'
                        });

                        saleOrderRecord.commitLine({
                            sublistId: 'item'
                        });
b
nope
thats for porate
which is not rate
g
I tried rate, had same error
b
unlikely
error message should be different
g
am trying set rate again, will let you know
s
with the field explorer, if you're trying to set the prorate, it looks like a 2d.p currency field
g
@battk setCurrentSublistText works, thank you very much
@Sciuridae54696d it doesn't work on porate
salesOrder.setCurrentSublistValue({             sublistId: 'item'             , fieldId: 'porate'             , value: '-11.99'         });
got error "type":"error.SuiteScriptError","name":"USER_ERROR","message":"Please enter a value for amount.", from aborve
will get same error if do salesOrder.setCurrentSublistText({             sublistId: 'item'             , fieldId: 'porate'             , text: '-11.99'         });
b
setCurrentSublistText is for when fields have different behaviors for different values
for example, the rate is normally a currency field, but can also be set with percentages
setValue works for the currency side, setText for percentages
its why i said in the beginning you have to do both of my suggestions
porate is just a normal currency field and has no percentage related behavior