Something strange on pageInit function (client scr...
# suitescript
d
Something strange on pageInit function (client script) I want to pop the lines of salesorder/purchase order by data I already have (rows)
Copy code
for (var i = 0; i < obj.rows.length; i++) {
                            console.log(i);
                            var row = obj.rows[i];
                            var item = row.item;
                            var qty = row.qty;
                            var rate = row.rate;


                            currRec.selectNewLine({sublistId: sublist});
                            currRec.setCurrentSublistValue({
                                sublistId: sublist, fieldId: itemField, value: item,
                            });
                            currRec.setCurrentSublistValue({
                                sublistId: sublist, fieldId: 'rate', value: rate,
                            });
                            currRec.setCurrentSublistValue({
                                sublistId: sublist, fieldId: 'quantity', value: qty, ignoreFieldChange: true
                            });
                            currRec.setCurrentSublistValue({
                                sublistId: sublist, fieldId: 'amount', value: rate,
                            });
                            currRec.commitLine({sublistId: sublist}); 
}
The problem is that its not iterate the loop and commit only the last row
1
its on type create so i cant have line numbers
Its not EDIT is CREATE
b
Copy code
setCurrentSublistValue
is actually asynchronous
you are committing before it completes
d
What to you mean? the commit happend before the setCurrent?
i tried to put delay before the commit and its dosent work
Oh i think i got you
forceSyncSourcing:true will set the function to be synchronously
now its working
thanks!