The Windhover
The Windhover

Reputation: 342

How do I add button in NetSuite client script and use it as trigger for script function?

I'm trying to add a button to the current record with the Client Script button definition on a script record, but for some reason it's not finding my function. I'm returning my function tryThisand there is a button on the page which I created on the script record with the function tryThis defined in the appropriate field, but the code doesn't run. Here's my script:

define (['N/currentRecord','N/search','N/record'] ,
function(currentRecord,search,record) {
    function tryThis(context){
        log.debug({
            title: 'try this', 
            details: 'try this'
            });         
    }
    function pageInit(context) {
    } 

    return {
        pageInit: pageInit,
        tryThis: tryThis
    };
});

Nothing happens :(

Yes, the script is deployed.

enter image description here

How can I use this button on a client script??

enter image description here

Upvotes: 1

Views: 3669

Answers (2)

dcrs
dcrs

Reputation: 304

At the bottom of your Client Script record in Edit mode you will find where you can easily set the button and function to call. enter image description here

Upvotes: 0

Krypton
Krypton

Reputation: 5231

This doesn't exactly answer your question directly, but I hope it may help. I tested this, and there appears to be nothing wrong with the way you've set it up - the only thing that seems to be not working is the log module, which I've come across before in client scripts.

Try running your function using a console.log() or alert() instead (both work for me).

Hopefully someone with more detailed knowledge of the N/log module's design and behavior will chip in, as the documentation seems to indicate that this should work.

Upvotes: 4

Related Questions