Making Sure Users Enter Unique Values
You can use validation to make sure the value that the user enters in a field is unique.
To make sure the user enters unique values
Make sure the form_validator object is defined.
For more information, see Preparing to Use Validation.
Add the following code to the forms.js file:
validator.validate_unique_fields(“fields_to_check“,“fields_to_highlight“,“strin g_key“,boolean_skip_empty_fields);
where:
fields_to_check is an array of fields. This array must be unique.
fields_to_highlight is an array of control identifiers that Siebel CRM Desktop highlights in the client if the validation fails.
string_key is the string key in the resource file that contains the text for the message that Siebel CRM Desktop displays in the client if the validation fails.
skip_empty_fields is an optional parameter that determines if Siebel CRM Desktop ignores empty fields when it compares records. You can set it to one of the following values:
true. Ignore empty fields.
false. do not ignore empty fields.
For example, the following code makes sure the user enters an opportunity name that is unique for a given account:
validator.validate_unique_fields(["Name", "AccountId"], ["opportunity","account_id"],"msg_opportunity_unique");
where:
["Name", "Account Id"]
identifies the fields that, when combined, must be unique. In this example, the Name field plus the Account Id field constitutes this unique combination.["opportunity","account_id"]
identifies the form controls that Siebel CRM Desktop highlights in the client if the validation fails. In this example, it highlights the control for the opportunity name and the control for the account name.msg_opportunity_unique identifies the string key in the resource file that contains the text for the message that Siebel CRM Desktop displays in the client if the validation fails.
Test your changes and then republish the customization package.
For more information, see Republishing Customization Packages.