Software Technology Tips

Add a Field Change event for Suitelet Form in Netsuite

Field Change Event for a Suitelet Page:

 

Let's we have a suitelet script where we have added two text boxes Roll No. and Name.

Now we want when we enter a Roll No., we want to populate its corresponding name in the Name text box.

 

Here is the sample suitelet script file:

SampleSuiteletScript.js

function CreateForm(request,response)

{

   var form = nlapiCreateForm(“Sample Form”, true);

   form.addField(“textroll”, “text”, “ROLL NO”); //Roll No Text Box

   form.addField(“textname”, “text”, “Name”); //Name Text Box

 

   //Add Client script “SampleClientScript” to suitelet form

   form.setScript(“customscript_sample_client_script”);

   form.addSubmitButton(“Submit”);

   response.writePage(form);

}

 

Now Create a Client script file which includes a function that will run on field change event of the Roll No. field of suitelet page:

SampleClientScript.js

 

//This is the field change event function

function SuiteletForm_FC(type, name)

{

   //Check if the field is Roll No

   if(name == “textroll”)

   {

      //Get Roll No. value

      var rollNo= nlapiGetFieldValue(“textroll”);

      //do whatever you want to get its corresponding name

      //let's take the corresponding name as "SET_NAME"

      //Set the Name in Name Field

      nlapiSetFieldValue(“textname”, "SET_NAME");

   }

}

 

Now create a Client script in Netsuite account and add the client script file(SampleClientScript.js ) there.

Put the function name(SuiteletForm_FC) in Field Change function text box in the script tab of that script page. Now save the client script without adding anything in deployment tab.

 

Then create a Suitelet script in Netsuite and add that suitelet script file(SampleSuiteletScript.js) and add the function name(CreateForm) in Function field of script page and follow required steps to save and deploy the script.

 

Now run the suitelet page and test the field change event of Roll No. field in Sample Form.

 


Related Tags:

Suitelet form Field Change, Client script, Suitelet, Field Change in Netsuite, Netsuite, Netsuite Field Change

Author: Ashabari Jena

.NET

Let us Connect!

iso 9001 QA25 Red Herring STPI D&B Fastest Growing SME 2013 Award zinnov Nasscom

copyright (c) Mindfire Solutions 2007-2014. Login