```if (context.type === context.UserEventType.EDIT...
# suitescript
m
Copy code
if (context.type === context.UserEventType.EDIT || context.type === context.UserEventType.CREATE) {
    //Run Function
}

if (context.type !== context.UserEventType.VIEW) {
    //Do not run function in view mode
}
This is inside the beforeLoad. The function in the second if statement should not run in edit mode - but it does, any ideas?
s
The second function should run in EDIT mode
EDIT !== VIEW is a true statement
c
You need to deal with COPY too
Oh, xedit too. That's the worst one to forget as you don't get the entire record context
m
thanks, will try and consider copy & xedit.
Copy code
if (context.type === context.UserEventType.EDIT || context.type === context.UserEventType.CREATE) {
    const address_list = context.form.addField({
        id: 'custpage_iss_address',
        type: serverWidget.FieldType.SELECT,
        label: 'Customer Address'
    });
}

if (context.type !== context.UserEventType.EDIT) {
    const current_record = context.newRecord;
    const customer_id = current_record.getValue({
        fieldId: 'company'
    });
    const address_set = PopulateAddress(current_record, customer_id);
}
still entering second if
actually this is working but something else in a client script is making the changes - so will try and work on the CS script