Tuesday 17 September 2019

Understand how to validate the Address record using suite Script?

In NetSuite, Address is a subrecord which is placed in the address subtab.


Now, i wanted to make "Phone" is mandatory.

Here is the process how can we go-ahead:

1. Login to NetSuite, Go to Customization -> Forms -> Address Forms.
2. Create a custom address form.
3. Make sure create a script to validate the phone number field, (Use only suitescript 1.0)

Sample code is below: (Used Client Script)

function ValidateAddress(type){

var phNum = nlapiGetFieldValue('addrphone');
if ((phNum == "") || (phNum == null)) {
alert ("Please enter the Phone number");
}

    return true;
}

4. Now go back to the custom address form, go to Custom code subtab, "Script File" select the
script, which is created in above step. Attach the script here like :
   
        In the script file field -> click on the "Plus(+)" button, a window popups:


5. Select the script file and close the window.
6. under the "Validate Field Function" field, select the function from the suitescript function where we had the validation logic (ex: i have mentioned ValidateAddress).

7. Save the form and the customization is completed.

Now, go to address subtab in employee, click on the pencil icon, the address subrecord will be opened, now click on the "Ok" button. the alert populates:



Thanks,
Ramu






No comments:

Post a Comment