I'm adding a new line to a sales order. After I've...
# suitescript
s
I'm adding a new line to a sales order. After I've entered the item, I have a client script that should show the rate, for some reason it show nothing. The logic is var record = context.currentRecord; var rate= parseInt(record.getCurrentSublistValue("item", "rate")); alert ('rate=' + rate); What am I doing wrong ?
b
more code needed, the timing about when you try to get values matters since suitescript methods are asynchronous in client script
s
this is the entire script /** * @NApiVersion 2.x * @NScriptType ClientScript * @NModuleScope SameAccount */ define(['N/currentRecord', 'N/log', 'N/search'], function(currentRecord, log, search) { function fieldChanged(context) { var record = context.currentRecord; if (context.fieldId == 'quantity' || context.fieldId == 'item') { var _rate = parseInt(record.getCurrentSublistValue("item", "rate")); alert ('rate=' + _rate); } //if (context.fieldId == 'item') { } return { fieldChanged: fieldChanged }; });
Well of a sudden, it decided to work. I don't understand but I'm happy
thanks all
b
its timing related, you are using the wrong entrypoint since the rate is calculated after the item or quantity is set
👍 1
you should be using postSourcing
s
Interesting. I will use it. Thanks a lot