Wednesday, March 13, 2019

Suitelet > Client Script > Deploying Client Script on Suitelet

1.        Create and Deploy a client script with the following code ( Customization > Scripting > Scripts > New > Client):

ID: customscript_client

function pageInit()

{

        nlapiSetFieldValue('custpage_testfield','Hello World');

}

 

2.        Place function 'pageInit'  Name in PageInit function field of the Client Script Record.

 

 

3.        Create the Suitelet Form below. This Suitelet Form will set the Client Script that will set the field to "Hello World" on pageInit.

ID: customscript_FormSuitelet

function formSuitelet(request, response) {

 

        if (request.getMethod() == 'GET') {

 

                var form = nlapiCreateForm('Test Form');

               

                form.addField('custpage_testfield', 'text', 'Name');

                form.addSubmitButton("Submit");

                form.setScript('customscript_client');

                response.writePage(form);

               

        }

}

 

Code Breakdown

The code line that adds the client script to the Suitelet Form is:

form.setScript('customscript_client');

 

Parameter

    script {string | int} [required]: Requires the scriptId or internal ID of the global client script used to enable Client SuiteScript on this form.



Disclaimer: The sample code described herein is provided on an"as is" basis, without warranty of any kind, to the fullest extentpermitted by law. NetSuite Inc. does not warrant or guarantee the individualsuccess developers may have in implementing the sample code on theirdevelopment platforms or in using their own Web server configurations.

NetSuite Inc.does not warrant, guarantee or make any representations regarding the use,results of use, accuracy, timeliness or completeness of any data or informationrelating to the sample code. NetSuite Inc. disclaims all warranties, express orimplied, and in particular, disclaims all warranties of merchantability,fitness for a particular purpose, and warranties related to the code, or anyservice or software related thereto.

NetSuite Inc. shall not be liablefor any direct, indirect or consequential damages or costs of any type arisingout of any action taken by you or others related to the sample code.

3 comments:

  1. where to deploy client script?

    ReplyDelete
    Replies
    1. Go to Customization > Scripting > Scripts > New

      Delete
  2. Hi! I'm doing something similar to this. Instead of a form, I have a list to show the results of a search.
    But my doubt it's about where to deploy the Client Script. I mean what does it apply to?

    ReplyDelete