I have a lotus script to update the incremental number in the profile document. It works well BUT stuff up if I don’t enter anything in the ChangeTitle field - which I have a validation check.
ChangeTitle validation formula:
@If(@IsDocBeingSaved & ChangeTitle=“”;@Failure(“Change request title is a mandatory field. Please fill in the Change Request Title”);@Success)
How do I update the profile field only if the whole document have been saved? HELP
Below is my code: how do i update the profile field only if the document is actually going to be save?
Sub Querysave(Source As Notesuidocument, Continue As Variant)
Dim session As New NotesSession
Dim db As NotesDatabase
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim pdoc As NotesDocument 'profile doc
Dim item As NotesItem
Dim pitem As NotesItem
Set db = session.CurrentDatabase
Set uidoc = workspace.CurrentDocument
Dim stringsqnumber As String
Dim stringpsqnumber As String
Dim pupdate As Variant
Set doc = uidoc.Document
If uidoc.IsNewDoc Then
Set pdoc = db.GetProfileDocument("CRProfile",)
Set pitem =pdoc.GetFirstItem("SqNumber")
stringpsqnumber=Cstr(pitem.Values(0)+1)
pdoc.SqNumber=stringpsqnumber
Call pdoc.save(False,False)
End If
Call doc.Save(False,False)
Do your field validation in the QuerySave instead of in the field validation formulas. I’m not a big fan of validating in the QS (since it hides validation from maintenance developers), but because the QS fires before @IsDocBeingSaved becomes true, it can sometimes be necessary.
You are absolute right - QS fires first before @isDocBeingSaved. I have so many fields to validate…how do i do a quick validate to check if a bunch of fields are not blank before saving
thanks what a nice validation application.I put the continue… at the top of QS. Works in the validation (bravo) but it’s still update my incremental profile number.
See…
Sub Querysave(Source As Notesuidocument, Continue As Variant)
'validation
continue = ValidateCRForm(Source)
Dim session As New NotesSession
Dim db As NotesDatabase