Example of Creating a Custom Validation
If the user enters a new opportunity, then the following code makes sure the close date that the user enters occurs later than the current date:
validator.add_custom(validate_close_date,["close_date"],"msg_opportunity_close_dat
e_validation");
To do the validation, this code calls the following validate_close_date function:
function validate_close_date()
{
var close_date = new Date(ctx.form.item.snapshot['Primary Revenue Close Date']);
var original_close_date = new Date(ctx.form.item['Primary Revenue Close Date']);
var today = new Date();
var utc_today = new
Date(today.getUTCFullYear(),today.getUTCMonth(),today.getUTCDate());
if (close_date != null)
{
return close_date < utc_today ? ((original_close_date + 0) == (close_date + 0) ?
true :
false ) : true;
}
else true;
}
For more information, see Customizing Form Functions. The following table decribes the parts of the validate_close_date function.
Code | Description |
---|---|
|
This code creates the close_date variable and sets the value for this variable to the following value: new This code does the following:
|
|
This code defines the original_close_date variable. Siebel CRM Desktop enters into this variable the value that the field contains when the user opens the form. To do this, it references the following items:
|
|
This code creates the following variable and enters the current date into this variable: today To support the UTC (Coordinated Universal Time) format that Siebel CRM uses, this code uses the following variable to create a UTC date: today |
|
This code does the following validation:
|