Tuesday, June 4, 2019

Ensure that a Role has been Selected for Contact Using SuiteScript

When creating a Contact record for a Customer, Vendor, Partner or Other Name the Role is not mandatory and it cannot be set as such for the moment.

Enhancement 221662 has been raised to add the ability to make the Contact Role mandatory for users to ensure that each contact has role category selected before save.

Alternate Solution using SuiteScript:
Display a message on Save when Role has not been selected so that the user will not be able to move forward without selecting one.

  1. Create a Client Script file with Save Record function having the code similar to the one below:
    function clientSaveRecord(){	var roleValue = nlapiGetFieldValue('contactrole'); 	if(roleValue != '')		 return true;	else		{		alert("Please select a Role for the Contact before saving!");				return false;		}}
  2. Upload the file in the File Cabinet
  3. Create the Client Script record in NetSuite and Deploy it on Contact Record. See SuiteAnswer ID 10553 for steps in creating a script record.

The script will display a popup message to the user letting him know that the Role is mandatory to be filled before saving the record.

No comments:

Post a Comment