George Mihaylov
George Mihaylov

Reputation: 281

Open popup before or after clicking the Workflow button in Netsuite

I have this code (Userevent script) which is working fine with my custom button,

function beforeLoad_addButton(type, form) {
    var url = nlapiResolveURL('SUITELET', '543', 'customdeploy1')+'&entity=' + nlapiGetRecordId() +  '&recordType=' + nlapiGetRecordType();
    var script = "win = window.open('" + url + "', 'win', 'resizable=0,scrollbars=0,width=450,height=300');";
    form.addButton('custpage_buttonalert', 'Add Memo', script);
}

but now I want to open this popup (Suitelet) from another button created with the Workflow. How I can hook onclick action on button created with the Workflow without interrupting the workflow.

Upvotes: 0

Views: 2037

Answers (1)

George Mihaylov
George Mihaylov

Reputation: 281

I managed to do it like this:

function beforeLoad_addButton(type, form) {
    var url = nlapiResolveURL('SUITELET', '424', 'customdeploy1')+'&entity=' + nlapiGetRecordId() +  '&recordType=' + nlapiGetRecordType();
    var script = "win = window.open('" + url + "', 'win', 'resizable=0,scrollbars=0,width=450,height=300');";
    form.addButton('custpage_buttonalert', 'Add Memo', script);

    var ids = ['custpageworkflow105', 'custpageworkflow128', 'custpageworkflow148', 'custpageworkflow106', 'custpageworkflow129', 'custpageworkflow149', 'custpageworkflow107', 'custpageworkflow130', 'custpageworkflow150'];
    var script1 = '';

    script1 += '<script>';

    ids.forEach(function(entry) {
            script1 += 'jQuery("#' + entry + '").click(function() {'+ script +'});';
    });

    script1 += '</script>'


    var newInlineHtmlField = form.addField('custpage_myinline','inlinehtml','',null,null);
        newInlineHtmlField.setDefaultValue(script1);
}

I'm injecting the Javascript in the form. Here, the "ids" array is containing the workflow button ID's. When one of the button is clicked the code in script1 variable is executed, after that the workflow is performed.

Upvotes: 1

Related Questions