Siebel CRM Desktop for IBM Notes Administration Guide > Customizing Siebel CRM Desktop > Validating the Data That Users Enter >
Creating Custom Validations
You can create a custom validation. To create custom validations
- Make sure the InitValidators procedure is defined in the class that the form references.
For more information, see Preparing to Use Validation.
- Open IBM Domino Designer, open the SBL.Forms script library, and then add the following code to the class that the form references:
vld.ValidateCustom ids_array_ex, validation_message, validation_callback, ""
where:
- Test your changes and then republish the customization package.
For more information, see Republishing Customization Packages.
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: Dim ValidationCallBackCloseDate As New ValidationOpportunityCloseDate(NewSmartArray().Add("CloseDateOnly")) vld.ValidateCustom NewSmartArray().Add("CloseDateOnly"), MSG_OPPORTUNITY_CLOSE_DATE_PASSED_OUT, ValidationCallBackCloseDate, ""
To do the validation, this code calls the following ValidationOpportunityCloseDate class: Private Class ValidationOpportunityCloseDate As CallbackValidation Sub New(Fields As ArrayEx) Set m_Fields = Fields End Sub
'Validate - validation implementation Function Validate(validationCtx As ValidationContext) As Boolean Dim Doc As DocumentEx Dim SavedDoc As DocumentEx Dim Item As Variant Dim EnteredDate As NotesDateTime Dim OriginalDate As NotesDateTime Dim CurrentDate As NotesDateTime Dim Field As String Dim i As Integer Dim DateWasNotChanged As Boolean
Set Doc = validationCtx.DocEx Set SavedDoc = validationCtx.DocBackendEx Set CurrentDate = New NotesDateTime("") CurrentDate.Setnow
Validate = True For i = 0 To m_Fields.Length - 1 Field = m_Fields.Item(i)
Set Item = Doc.FirstItem(Field) Set EnteredDate = New NotesDateTime(Item.Text) Set Item = SavedDoc.FirstItem(Field) DateWasNotChanged = False If Not Item Is Nothing Then Set OriginalDate = New NotesDateTime(Item.Text) DateWasNotChanged = (EnteredDate.Timedifference(OriginalDate) = 0) End If
If EnteredDate.IsValidDate Then Validate = DateWasNotChanged Or (EnteredDate.TimeDifference(CurrentDate) >= 0) End If
If Validate = False Then Exit For End If Next End Function End Class
|