Learning NetSuite and need help with a simple prac...
# general
g
Learning NetSuite and need help with a simple practice project. I have a UE script that creates two buttons. I have another script that console.logs “Hello world” when these buttons are pressed. I’m not getting any errors, but neither is my code working. Here’s the UE function
Copy code
function handleBeforeLoad(context) {
        if (context.type != 'view') { return false; }
        
        enums.buttonArray.forEach(button => {
            context.form.addButton(button);
        })

        context.form.clientScriptModulePath = "SuiteScripts/sr_custom_button_press_cl.js";
        
    }
Here’s the enum.js
Copy code
define([], function () {
    const exports = {}
    const buttonArray = [
        { 
            id: 'custpage_btn_spcl', 
            label: 'Special', 
            functionName: "greet"
        },
        { 
            id: 'custpage_btn_ord', 
            label: 'Ordinary',
            functionName: "greet"
        }
    ]

    
    exports.buttonArray = buttonArray
    return exports
});
Here’s the function that is supposed to run when either of the two buttons are pressed.
Copy code
define([], function () {
    /**
     * @NApiVersion 2.x
     * @author Wes
     */
    var exports = {};

    function greet() {
        log.debug('My Greeting', 'Hello world')
        console.log('Hello world');
        alert('Hello world')
    }

    exports.greet = greet;
    return exports;
});
e
How are you referencing the module that has the enum?
g
On the first line of the UE function, I have this
define(['./enums'], function (enums) {
s
you probably need an empty pageInit on your client script file for it to be valid
g
Lemme give it a shot
s
Also in the future, I would post in #C29HQS63G and reply to original post with the screen shots rather than posting giant screenshots to take up the channel
g
Okay, thanks
Yea, still can’t get it to work
s
try to change your
functionName: "greet()"
I would also remove
log.debug()
from your client since it's not deployed and just stick with console/alert
g
Nothing
s
script tags should be at the top of the file, nothing above them
b
code looks ok
g
shouldn't comment
Copy code
/**
     * @NApiVersion 2.x
     * @author Wes
     */
on top of the script
b
start looking at problems with your script deployment