Can someone provide example to call Client script ...
# suitescript
d
Can someone provide example to call Client script in suitelet 2.0
b
what does the file record for PaymentValidation.js look like
what does your suitelet script deployment look like
d
Copy code
/**
 *@NApiVersion 2.x
 *@NScriptType Suitelet
 * Reports Payment Page - 12-17-2019
 */
define(["N/redirect", "N/runtime", "N/ui/serverWidget", "N/url"],
    function (redirect, runtime, ui, url) {
        function showPaymentForm(context) {
            var form = ui.createForm({
                title: 'Reports Payment Form'
            });
            log.debug("I m above");
            
            
            // var pageInits = function () {
            //     log.debug("I m pageinit");
            // }
            form.clientScriptModulePath = "../ClientScripts/PaymentValidation.js";
            form.addButton({
                id: 'custpage_cre_view_agreement',
                label: 'Print Retainer',
                functionName: 'form.clientScriptModulePath.customSubmit'
            });


        
            context.response.writePage(form);
        }

        

        function onRequest(context) {
            if (context.request.method === 'POST') {
                var currentScript = runtime.getCurrentScript();
                log.debug("Params =>", context.request.parameters);
                var params = {};
                for (var k in context.request.parameters) {
                    if (k.indexOf('custpage_') == 0 && k.indexOf('custpage_transactions') == -1) {
                        if ((/^custpage_.*_display$/).test(k))
                            continue;
                        params[k] = context.request.parameters[k];
                    }
                }
                redirect.toSuitelet({
                    scriptId: currentScript.id,
                    deploymentId: currentScript.deploymentId,
                    parameters: params
                });
                return;
            }
            showPaymentForm(context);
        }
        return {
            onRequest: onRequest
        };
    });
Copy code
/**
*@NApiVersion 2.0
*@NScriptType ClientScript
*/
define([], function(){
	var pageInit = function() { } //just to add an entry point

	var customSubmit = function() {
		log.debug("sss")
	}
return {
		pageInit: pageInit,
	customSubmit: customSubmit
}
});
@battk
b
those are the files
interested in the records in netsuite
d
message has been deleted
b
that is the form generated by the suitelet
d
What records I didn't get you?
b
the deployment of the suitelet
d
is this what you mean
b
and the file record in netsuite for PaymentValidation.js
navigate through the file cabinet to PaymentValidation.js and click edit to bring up the file record
d
@battk
b
looks functional to me
change your functionName back to customSubmit should make it work normally
d
message has been deleted
i changed it to use console.log instead for thee button
d
message has been deleted
it is working fine any changes for me?
message has been deleted
b
nothing significant
Copy code
/**
 *@NApiVersion 2.x
 *@NScriptType Suitelet
 * Reports Payment Page - 12-17-2019
 */
define(["N/redirect", "N/runtime", "N/ui/serverWidget", "N/url"],
    function (redirect, runtime, ui, url) {
        function showPaymentForm(context) {
            var form = ui.createForm({
                title: 'Reports Payment Form'
            });
            log.debug("I m above");
            // var pageInits = function () {
            //     log.debug("I m pageinit");
            // }
            form.clientScriptModulePath = "./client.js";
            form.addButton({
                id: 'custpage_cre_view_agreement',
                label: 'Print Retainer',
                functionName: 'customSubmit'
            });
            context.response.writePage(form);
        }
        function onRequest(context) {
            if (context.request.method === 'POST') {
                var currentScript = runtime.getCurrentScript();
                log.debug("Params =>", context.request.parameters);
                var params = {};
                for (var k in context.request.parameters) {
                    if (k.indexOf('custpage_') == 0 && k.indexOf('custpage_transactions') == -1) {
                        if ((/^custpage_.*_display$/).test(k))
                            continue;
                        params[k] = context.request.parameters[k];
                    }
                }
                redirect.toSuitelet({
                    scriptId: currentScript.id,
                    deploymentId: currentScript.deploymentId,
                    parameters: params
                });
                return;
            }
            showPaymentForm(context);
        }
        return {
            onRequest: onRequest
        };
    });
Copy code
/**
*@NApiVersion 2.0
*@NScriptType ClientScript
*/
define([], function(){
	var pageInit = function() { } //just to add an entry point
	var customSubmit = function() {
		console.log('sss')
	}
return {
		pageInit: pageInit,
	customSubmit: customSubmit
}
});
d
@battk client.js?
b
that was my path to your client script
d
I think some issue with Settings in Netsuite?
b
i didnt see any weird settings when you shared your files record or script deployment
you can try deleting them and then recreating them
d
Ok let me do it once again
N.js?NS_VER=2019.2.0&minver=110:15897 Uncaught USER_ERROR: Can't display page for 4487041_SB1.  This company is currently not operating its Web site.<br><br>If you expected a Web site, Web store, registration form or customer center at this address, it may be out of service temporarily.  Please check back later.
Is this the reason?
@battk?
message has been deleted
b
that looks extra weird
did you setup the script deployment correctly
d
Yes
@battk
b
what does the script deployment record look like
d
Copy code
/**
 *@NApiVersion 2.x
 *@NScriptType Suitelet
 * Reports Payment Page - 12-17-2019
 */
define(["N/redirect", "N/runtime", "N/ui/serverWidget", "N/url"],
    function (redirect, runtime, ui, url) {
        function showPaymentForm(context) {
            var form = ui.createForm({
                title: 'Reports Payment Form'
            });
            log.debug("I m above");
            // var pageInits = function () {
            //     log.debug("I m pageinit");
            // }
            form.clientScriptModulePath = "./client.js";
            form.addButton({
                id: 'custpage_cre_view_agreement',
                label: 'Print Retainer',
                functionName: 'customSubmit'
            });
            context.response.writePage(form);
        }
        function onRequest(context) {
            if (context.request.method === 'POST') {
                var currentScript = runtime.getCurrentScript();
                log.debug("Params =>", context.request.parameters);
                var params = {};
                for (var k in context.request.parameters) {
                    if (k.indexOf('custpage_') == 0 && k.indexOf('custpage_transactions') == -1) {
                        if ((/^custpage_.*_display$/).test(k))
                            continue;
                        params[k] = context.request.parameters[k];
                    }
                }
                redirect.toSuitelet({
                    scriptId: currentScript.id,
                    deploymentId: currentScript.deploymentId,
                    parameters: params
                });
                return;
            }
            showPaymentForm(context);
        }
        return {
            onRequest: onRequest
        };
    });
message has been deleted
b
the audience subtab?
d
message has been deleted
b
still looks normal
is there any error if your client scripts functions are empty?
d
I didn't tried it?
Only issue I see at my end is Client script is not included properly
viewsource