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. andName.
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:
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
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:
//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
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.