Querrysave problem

I’ve got a form with a Time/Date field called Target. I’ve got the following script in the Querrysave event, but it’s not quite working. I’ve watched the variables and the source.document.Target field in the LotusScript debugger and it appears to be working, but the changed date is not in the record afterwards. The point of the whole thing is to push the target date out to Monday if it would fall on a weekend.

Sub Querysave(Source As Notesuidocument, Continue As Variant)

Dim DateVar As NotesDateTime

Dim item As NotesItem

Dim wd As Integer



If source.IsNewDoc Then

	Set item = source.document.GetFirstItem( "Target" )

	wd% = Weekday(source.FieldGetText( "Target" ))

	If wd = 1 Then 

		'Target is a Sunday

		Set DateVar = item.DateTimeValue

		Call DateVar.AdjustDay(1,True)

		Set item.DateTimeValue = DateVar

	Elseif  wd = 7 Then 

		'Target is a Saturday

		Set DateVar = item.DateTimeValue

		Call DateVar.AdjustDay(2,True)

		Set item.DateTimeValue = DateVar

	End If

End If

End Sub

Subject: Querrysave problem

Why a QuerySave? Use an Input Translation in Target (or, if it’s a computed field, adjust the formula) instead:

@Adjust(Target;0;0;@Select(@Weekday(Target;1;0;0;0;0;0;2);0;0;0)

Subject: RE: Querrysave problem

Stan,

I was doing it in the querrysave becase the Target field is a computed field with the following value formula already in it. If I could figure out how to do it all in the value formula, I would.

@If(Severity=“Urgent”; @Adjust( TimeSubmitted; 0; 0; 1; 0; 0; 0); Severity=“Normal”; @Adjust( TimeSubmitted; 0; 0; 3; 0; 0; 0); “”:wink:

Subject: RE: Querrysave problem

Assign your current value to a variable,and then adjust it if it’s a date:

rawVal := @If(Severity=“Urgent”; @Adjust( TimeSubmitted; 0; 0; 1; 0; 0; 0); Severity=“Normal”; @Adjust( TimeSubmitted; 0; 0; 3; 0; 0; 0); “”);

@If(rawVal = “”; “”; @Adjust(rawVal;0;0;@Select(@Weekday(rawVal);1;0;0;0;0;0;2);0;0;0))