// *@NApiVersion 2.x *@NScriptType ClientScript ...
# suitescript
r
// *@NApiVersion 2.x *@NScriptType ClientScript */ define(['N/log'], function(log) { function fieldChanged(context) { if(context.mode !== 'edit' || context.mode !== 'create' || context.mode !== 'view'){ return; }; var currentRecord = context.currentRecord; var sublistName = context.sublistId; var fieldName = context.fieldId; var rate = currentRecord.getCurrentSublistValue({ sublistId:'item', fieldId:'rate' }); log.debug('rate',rate); var qty = currentRecord.getCurrentSublistValue({ sublistId:'item', fieldId:'quantity', }); var multi = rate * qty; var line = context.line; if (fieldName === 'item' && sublistName === 'item') currentRecord.setCurrentSublistValue({ sublistId:'item', fieldId: 'custcol_averagecostofitem', value: rate * qty }); log.debug('multi',multi); } return { fieldChanged: fieldChanged, } });
b
Copy code
(context.mode !== 'edit' || context.mode !== 'create' || context.mode !== 'view')
is equivalent to true
r
yeah i removed that, still the output is showing in execution log but at the field it is showing 0, field type is free form text, i changed it to decimal still no output
b
not really enough information to tell whats going on
i dont know what logs you are seeing
you are probably using the wrong entry point, the rate will be sourced from the item
which means you should be using postSourcing
r
thanks worked, but i have this
this is the output, 200 is the custom field from which i taking the value and multiplying it by qty and showing NaN
b
now you need to pay attention to the values of qty and avgcust
importantly the type and the value
r
Actually the field type is free form text maybe that's the problem, I tried to change the the field but fld_val_error is showing. Idk it was working just fine and I add a few debug ok lines to this and it stops working. Idk what's wrong. Now it is showing no log too
b
whats the value of
qty
r
I am still trying value of qty is not showing... No execution log is executing ..now
Am I going wrong
Somewhere
b
are you still using the same code?