Validate script examples
Example 1
This example adds a Validate Script, which checks the validity of the Opportunity Certainty field. If the field value is set to less than 25%, it expects the Opportunity Priority to be set to Low. If this is not the case, a validation error message is displayed to the user.
- Click <My Profile> | Administration | Customization.
- Select Opportunity Progress from Secondary Entities.
- Click the Screens tab.
- Click Opportunity Status Box.
- Select OpportunityProgress: Priority in the Screen Contents panel.
- Type the following script in Validate Script.Copy
if (Values('oppo_certainty')<25 && Values('oppo_priority')!='Low')
{
Valid=false;
ErrorStr="please set the priority to Low";
} - Click Update and then click Save.
- Add a new opportunity, set the Priority to 20 and click Save. A validation error is displayed to the user with the error you specified.
Example 2
You can add a Validate Script, which validates that every customer who is buying a License is assigned a Customer Reference ID that begins with the letter 'L'. Otherwise it displays an error message.
- Click <My Profile> | Administration | Customization | Primary Entities | Opportunity, and click the Screens tab.
- Click Opportunity Detail Screen.
- Select Opportunity : Customer Ref.
- Enter the following script in ValidateScript:Copy
custref=Values('oppo_customerref')+'';
if ((Values('oppo_type')=='License') && (custref.charAt(0)!='L'))
{
ErrorStr='!'+custref+'The customer reference must begin with L';
Valid=false;
} - Click Update and then click Save.
- Create a new opportunity, select License from Type, enter a customer reference number beginning with any letter except L.
- Click Save. The error displayed indicates that this type of opportunity must be assigned a customer reference beginning with L.
