Hi @channel I’m attempting to set sublist value th...
# suitescript
d
Hi @channel I’m attempting to set sublist value through aftersubmit function(2.0) on sales order. the field I’m trying to change is commit field which is netsuite’s field. The problem is that when I set the value it sets it however, when I check the record it does not reflect on SO. here is the code snippet. try{ if (context.type == context.UserEventType.EDIT) { var rec = context.newRecord; var lineCount = rec.getLineCount({sublistId:‘item’}); log.debug({title:‘changing the commit status’,details:lineCount}); for(var i=0;i<lineCount;i++){ var createpo = rec.getSublistValue({ sublistId:‘item’, fieldId:‘createpo’, line: i }); log.debug({title:‘createpo has value’,details:createpo}); if(createpo== ‘’ || createpo == undefined || createpo == null) { log.debug({title:‘inside if to set value’,details:“”}); rec.setSublistValue({ sublistId:‘item’, fieldId:‘commitinventory’, line:i, value:1 }); log.debug({title:‘value set’,details:“”}); var temp = rec.getSublistValue({ sublistId:‘item’, fieldId:‘commitinventory’, line:i, }); log.debug({title:‘value of commit’,details:temp}); rec.save(); } } } } catch(e) { log.debug(“log error in the 652 try catch block”+e); }
s
You cannot change records in after submit without loading/saving. You're
rec = context.newRecord
, but then you have a
rec.save()
, those 2 things do not go together. Is there a reason you want to do this
afterSubmit
instead of
beforeSubmit
?
c
aftersubmit
is too late. The record has already been submitted/saved to the database. Either move it to a
beforesubmit
or use
record.load()
/
record.save()
in your
aftersubmit
s
jinx
d
correct
c
lol
d
i realized it now. Lol
c
Also, please don't ever try and do @ chan - it notifies 3 thousand people (when it's enabled on the channel). Very rude
d
ohh I’m sorry but I never get response from anyone that is the reason I do it
c
If your question is sane, people will answer. Maybe not instantly
d
ok