Hi everyone, I'm trying to add a button to a form ...
# suitescript
e
Hi everyone, I'm trying to add a button to a form on a sublist, this is what I have: const itemSublist = form.getSublist({ id: 'item' });         itemSublist.addButton({             id: 'custpage_update_item_prices_sublist',             label: 'bottom Update Prices',             functionName: 'openUpdateSuitelet'         }); unfortunately, this is not working. any ideas?? Thank You!
b
you need to better explain your problem
not working
by itself is not good enough
plusone 1
e
it works by the edit mode but not view, just realized
s
If you notice on your transactions, none of sublist buttons (even the native ones) appear in View mode, likely by design but never tried personally
c
Reasonable to say this logic is under a context type of edit and not view so its only showing on edit. I add buttons in view mode all the time.
s
@creece I created a clean script with nothing else running on page and my sublist button did not show up in View mode on a sales order, but it does appear in Edit mode. It logs that it entered the beforeLoad function, but did not show the button. Edit:
Copy code
/**
 * @NApiVersion 2.1
 * @NScriptType UserEventScript
 */
define([], () => {
    return {
        beforeLoad: (context) => {
            log.debug(context.type, 'is this triggered in VIEW MODE?');
            context.form.getSublist('item')
                .addButton({
                    id: 'custpage_test1',
                    label: 'Does this button show up?',
                    functionName: 'someFn'
                });
        }
    }
});
c
I saw it as adding a button I did not see the sublist part. That's my bad.
s
Yeah I think if you want the button to show up, just put it at the top instead of as a sublist button.