Hello, i have a question: in a UserEvent script, ...
# suitescript
t
Hello, i have a question: in a UserEvent script, do you know why in XEDIT the itemCount will return 0 but in EDIT, it will work well and return the right number of lines ?
function _beforeSubmit(scriptContext) {
let recOpp = scriptContext.newRecord;
let opType = scriptContext.type;
let itemCount = recOpp.getLineCount({sublistId: 'item'});
a
Normally XEDIT only exposes the fields that were modified/updated and nothing else, so you will only have access to the fields and values that were modified, since sublists can’t be modified via XEDIT is normal they are null/empty.
r
Either use load and save instead of submitfield in the other script which is trying to update the record your userevent is deployed on Or Load the record in userevent instead of getting the data from context.newrecord.
t
I wanted to avoid load but i'll use it. thanks a lot.
b
Use Search instead of load, it's way faster, but harder to code, worth it IMHO
t
@borncorp but the idea is to trigger userEvent scripts, so search will not work.
b
@t_gdb I was saying that if you go with modifying the UE, then in your UE if type = XEDIT then run a search instead getting the data from context.newrecord.
t
understood. Thanks. but here they don"t want to edit the triggered UE script.