Hi, On user event script I am trying to add column...
# suitescript
d
Hi, On user event script I am trying to add column to a sublist (Item Group record):
Copy code
const beforeLoad = (scriptContext) => {

            if (scriptContext.type === scriptContext.UserEventType.VIEW || scriptContext.type === scriptContext.UserEventType.EDIT) {
                let form = scriptContext.form;
                let componentsSublist = form.getSublist('member');

                log.debug('componentsSublist', JSON.stringify(componentsSublist));

                componentsSublist.addField({
                    id: 'custpage_test',
                    type: serverWidget.FieldType.INTEGER,
                    label: 'Test'
                });
            }
}
But I can see the field only on EDIT, and also when I set value to that field its not save it and the field disappear after saving the record (VIEW) Any solution?
c
Fields added in that way are not permanent and do not persist. You need to add an actual custom field via the UI
💯 1
d
But I have to do it inside the sublist that cant be change in UI so I cant?
d
you could serialize the values in the sublist to a custom body field on save and deserialize on beforeLoad
if the values you're adding exist on the member items' records, consider whether a custom sublist showing these values would be a better solution