Input validation not acting as required

I have two fields (“NotesVisitorName” and “Status”) at top of my form - they are the first ones that the user sees in that order. The “NotesVisitorName” field displays a list of visitors based on a @DBColumn formula and refreshes fields on keyword change. Its Input Validation formula is :@If(Status = “” & NotesVisitorName = “” ; “Please select the visitor name.” ; @Success).

The Status field is a CheckBox type of field and if the user selects it several fields disappear and others appear based on hide-when formulas.

The problem is that when the user has not selected anything in the NotesVisitorName field and tries to put a checkmark in the Status field the input validation for the NotesVisitorName field kicks in.

How can I prevent this without having to make a selection in the NotesVisitorName field and select the Status field and still get the other fields to refresh on keyword change ?

Thanks a bunch,

Dan

Subject: Hide whens can quickly solve this…

If there are just the two fields simply hide the status field until they fill out the visitor field.

I’m pretty anti input validation. I prefer doing all my validation on save or submit in one fell swoop.

Subject: RE: Hide whens can quickly solve this…

Hi Radio Head,thanks for your suggestion. I attempted something in the QuerySave event of the form but after the validation takes place, I get kivked out of the application. By the way is there a way that only one msg be presented on the screen and then return the user to the appropriate field (I have never done that)?

Thanks,

Dan

Here is what I have:

Sub Querysave(Source As Notesuidocument, Continue As Variant)

Dim s As New NotesSession

Dim db As NotesDatabase

Dim w As New NotesUIWorkspace

Dim doc As NotesDocument

Dim item As NotesItem

Dim dt As NotesDateTime

Set db = s.CurrentDatabase 

Set doc = Source.Document



bSaved = False



 'Dont let it save until continue = true

Continue = False

‘XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

   'validate entries



If doc.Status(0) = "" And doc.VisitorName(0) = "" Then

	Msgbox "Missing entry for Visitor Name!", MB_ICONSTOP, "Save & Close"

	source.GoToField (" VisitorName")

Else

	If doc.Status(0) = "New/Nouveau" And doc.NewVisitorName(0) = "" Then

		Msgbox "Missing entry for Visitor Name!", MB_ICONSTOP, "Save & Close"

		source.GoToField (" NewVisitorName")

	End If			

End If



If doc.Status(0) = "New/Nouveau" And doc.NewCompanyName(0) = "" Then

	Msgbox "Missing entry for Company Name!", MB_ICONSTOP, "Save & Close"

	source.GoToField (" CompanyName")

End If



If doc.Names(0) = "" Then

	Msgbox "Missing entry for Person visited!", MB_ICONSTOP, "Save & Close"

	source.GoToField (" Names")

End If



If doc.Region(0) = "" Then

	Msgbox "Missing entry for Region!", MB_ICONSTOP, "Save & Close"

	source.GoToField ("Region")

End If



If doc.Location(0) = "" Then

	Msgbox "Missing entry for Location!", MB_ICONSTOP, "Save & Close"

	source.GoToField ("Location")

End If

‘XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Set dt = New NotesDateTime("1/1/1980")

Call dt.SetNow()

Set item = doc.ReplaceItemValue( "ModifyDate", dt.LSLocalTime)

Set item = doc.ReplaceItemValue( "Modifier", s.CommonUserName)



'set the date fields so they have the time after them

Set dt = New NotesDateTime(doc.AwayFrom(0))

Set item = doc.ReplaceItemValue( "AwayFrom", dt.LSLocalTime)

Set dt = New NotesDateTime(doc.BackOn(0))

Set item = doc.ReplaceItemValue( "BackOn", dt.LSLocalTime)

Set dt = New NotesDateTime(doc.AwayFromTime(0))

Set item = doc.ReplaceItemValue( "AwayFromTime", dt.TimeOnly)

Set dt = New NotesDateTime(doc.BackOnTime(0))

Set item = doc.ReplaceItemValue( "BackOnTime", dt.TimeOnly)

  'all OK

Continue = True

bSaved = True

'==============================================================

'Msgbox( "Strarting Agent - NewVisitorProfile_Notes ")

’ Handle New Visitor Request

'If the Status field is = “New” then create a separate visitor profile document

'Msgbox( "Break 1")

If ( doc.Status(0) = "New/Nouveau" ) Then

	

	FName$ = doc.FName(0)

	LName$ = doc.LName(0)

	CompanyName$ = doc.CompanyName(0)

	CompanyAddress$ = doc.CompanyAddress(0)

	CompanyCity$ = doc.CompanyCity(0)

	CompanyProvState$ = doc.CompanyProvState(0)

	CompanyPostalCode$ = doc.CompanyPostalCode(0)

	CompanyPhone$ = doc.CompanyPhone(0)

	CompanyFax$ = doc.CompanyFax(0)

	CompanyCell$ = doc.CompanyCell(0)

	

	Dim profiledoc As NotesDocument

	Set profiledoc = db.CreateDocument

	'Msgbox( "Break 2")

	

	'Pass the values from the current web document to the Visitor Information Profile form and save it

	profiledoc.Form = "Visitor Information"

	profiledoc.FirstName = FName$ 

	profiledoc.LastName = LName$ 

	profiledoc.CompanyName = CompanyName$ 

	profiledoc.MainAddress = CompanyAddress$ 

	profiledoc.City = CompanyCity$ 

	profiledoc.Province = CompanyProvState$ 

	profiledoc.PostCode = CompanyPostalCode$ 

	profiledoc.PhoneNum = CompanyPhone$ 

	profiledoc.FaxNum = CompanyFax$ 

	profiledoc.CellNum = CompanyCell$ 

	'Msgbox( "Break 3")

	Call profiledoc.Save(True,True)

	

End If		

'Msgbox( "Ending  Agent - NewVisitorProfile")

'===================================================================

End Sub

Subject: RE: Hide whens can quickly solve this…

This all depends on if you’re developing for web or client. But here’s a very easy client code that I put on a button that would do the validation on click of action button. You just need to put in a flag of some sort to ensure they use the action button.

@Command([ViewRefreshFields]);

@If(

FirstName=“”; @Return(@Prompt([Ok];“Required Field Error!”;“Please include the employee’s name!”));

LastName=“”; @Return(@Prompt([Ok];“Required Field Error!”;“Please include the employee’s name!”));

@Do(

@SetField( “Status” ; “Open”);

@PostedCommand([FileSave]);

@PostedCommand([FileCloseWindow])

))

Flip side, if you’re using JavaScript there are tons of great examples on this forum as well as others all over the web. Search for javascript validation on yahoo or google. It’s amazing how sharing programers are.

Subject: RE: Input validation not acting as required

@If(!@IsDocBeingSaved; @Success; Status = “” & NotesVisitorName = “” ; “Please select the visitor name.” ; @Success)

But I don’t understand why you’re testing Status here. If Status is not blank they are not required to enter a visitor name? If Status and VisitorName are both blank they are prompted to enter a visitor name – though they apparently can get away with not entering one if they do enter a Status. I don’t understand what you’re trying to do there.

Subject: RE: Input validation not acting as required

Sorry we just wnet through a power outage.OK, what I am trying to do here is display a list of existing visitors to pick from. However, if the user select “New” (Status checkbox field) the list disappears and the NewVisitorName appears. I do have a third field called VisitorName which is computed and has the following formula:

@If(Status != “” ; @Trim(NewVisitorName) ; @Trim(NotesVisitorName))

The purpose of the “Status” field is to get the user to create an additional visitor tracking document as well as a new visitor profile document (LS code in save action gets executed) which gets stored in a separate view which is used to display the LIST of existing visitors (ultimately in the NotesVisitorName dialog list field).

Hope this info helps,

Dan

Subject: Input validation not acting as required

I think you are validating 2 fields together. That is fine. In this case you have to put validation for Status field also. Then you have to validate the NotesVisitorname based on Status field value.

eg. @if(Status=“Open” & NotesVisitorName=“”;@failure(“Please select the visitor name”);@Success)

Subject: RE: Input validation not acting as required

forget Input validation.

force the user to use an OK button or write all your validation code in the onSubmit event or querysave.

ST