Isdocbeingsaved & lotus script

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

Subject: isdocbeingsaved & lotus script

Where is the code that updates the incremental number on your form and can you please paste the exact copy of the code here.

Subject: RE: isdocbeingsaved & lotus script

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)

End Sub

Subject: RE: isdocbeingsaved & lotus script

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.

Subject: RE: isdocbeingsaved & lotus script

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

Subject: RE: isdocbeingsaved & lotus script

Try this:

http://www.openntf.org/Projects/pmt.nsf/ProjectLookup/FieldValidator

Subject: RE: isdocbeingsaved & lotus script

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

what do I do next to fix this issue…

Subject: RE: isdocbeingsaved & lotus script

Right after this line:

continue = ValidateCRForm(Source)

put this:

If Not (continue) Then Exit Sub

That will skip all of your QS code, but still return False to the QS event.

Subject: RE: isdocbeingsaved & lotus script

thank you so much. it took me 2 days to resolve this; but with your help, just a few minutes. I really appreciate it. My ls skills are really rusty.

Subject: isdocbeingsaved & lotus script

Are you updating the profile document in an event? QuerySave? PostSave? QueryClose? or using a button or something?

I’m guessing it’s in the QuerySave. If so have you considered moving it to the PostSave?