Input validation failure is a little rough

I have input validation in some of my fields in my form. Currently its in my Input Validation.

If I leave one of the validated fields empty I get a prompt telling me that there are no names to send mail to. It also prompts me asking if I want to save the document.

What can I do to make this a little less rough for the user? Thanks!

My Save button code:

FIELD SaveOptions := “1”;

@PostedCommand([FileSave]);

@PostedCommand([FileCloseWindow])

QuerySave Code:

Sub Querysave(Source As Notesuidocument, Continue As Variant)

'Get a handle on the Notes Session

Dim session As New NotesSession

'Get a handle on the Current NotesUIWorkspace

Dim ws As New NotesUIWorkspace

'Get a handle on the uidoc and underlying document

Dim uidoc As NotesUIDocument

Set uidoc=ws.CurrentDocument

'Get a handle on the current database

Dim db As NotesDatabase

Set db = session.CurrentDatabase

'Assign variables

Dim IssueNum As String

Dim SendTo_1 As Variant

Dim docCurrent As NotesDocument

Set docCurrent = uidoc.Document

Dim tmp As String

Dim Assignees As String

Dim agent As NotesAgent

Dim rtitem As NotesRichTextItem

Set agent = db.GetAgent("Set Sequential Number")

Call agent.run





If docCurrent.Assignees(0) <> docCurrent.tmpAssignees(0) Then

	'Present the dialogbox

	

	docCurrent.Form = "Memo" 

	Call ws.DialogBox( "dlgTest", True, True, True, False, False, False, "Message Content Only")

	

End If



docCurrent.tmpAssignees=""

docCurrent.SendTo = docCurrent.Assignees

docCurrent.Subject = docCurrent.Subject_1

docCurrent.Body = docCurrent.Body1







Set rtitem = New NotesRichTextItem( docCurrent, "Body" )

'Call rtitem.AppendText( docCurrent, "Body" )

Call rtitem.AddNewLine( 1 )

Call rtitem.AppendDocLink( db, db.Title )





'Dim docCurrent As NotesDocument

Set docCurrent=source.Document

If docCurrent.pctComplete(0)="100" Then

	docCurrent.reqStatus="Complete"

End If

If docCurrent.reqStatus(0)="Complete" Then

	docCurrent.pctComplete="100"

End If



'Call docCurrent.Save (True, False)

Call docCurrent.send(False)

Call docCurrent.save(True, True )

End Sub

Input Validation Code:

@If(reqDescription= “”; @Failure(“Please enter a brief description”); @Success)

Subject: Just change your Save button a little…

@If(@Command([FileSave]); @Command([FileCloseWindow]); “”)

Subject: Input validation failure is a little rough…

Angie,

Here is an example how to do this step by step:

  1. Create a Script Library with a name of “ProcessDocument”

  2. Create a subroutine in there called DocumentSubmit

Sub documentSubmit (ws as NotesUIWorkspace, docCurrent as NotesDocument)

'THEN EITHER

  1. Add something similar to this to the QuerySave event:

'IN THE OPTIONS OBJECT PUT

Use “ProcessDocument”

'THEN

Sub Querysave(Source As Notesuidocument, Continue As Variant)

Dim ws As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Dim docCurrent As NotesDocument

Set uidoc = ws.CurrentDocument

Set docCurrent = uidoc.Document

Dim msg As String

msg = “”

'THIS VALIDATION ROUTINE ASSEMBLES ALL THE

'BAD/INCORRECT FIELDS AND DISPLAYS ONE DIALOG

'BOX. IF IT PASSES, IT CALLS THE SUBROUTINE

If docCurrent.Field1_Name(0) = “” Then

msg = msg + | → Field1 | & Chr(10)

End If

If docCurrent.Field2_Name(0) = “” Then

msg = msg + | → Field2 | & Chr(10)

End If

'etc etc

If msg <> “” Then

Msgbox | The following fields are required: | & Chr(10) & msg , 16, “Error”

Continue = False

else

Call documentSubmit (ws, docCurrent)

'NOTE THAT YOU WILL NEED TO REMOVE YOUR

'DECLARATIONS/SET FOR DOCCURRENT, UIDOC AND

'WORKSPACE IN THE SCRIPT LIBRARY SUBROUTINE

End If

End Sub

'OR

  1. Put this code in your PostSave event:

Sub Postsave(Source As Notesuidocument)

Dim ws As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Dim docCurrent As NotesDocument

Set uidoc = ws.CurrentDocument

Set docCurrent = uidoc.Document

Call documentSubmit (ws, docCurrent)

'NOTE THAT YOU WILL NEED TO REMOVE YOUR

'DECLARATIONS/SET FOR DOCCURRENT, UIDOC AND

'WORKSPACE IN THE SCRIPT LIBRARY SUBROUTINE

End Sub

NOTE: Even though source is the uidocument, i still declare and set uidoc for my readability of portable code)

Subject: RE: Input validation failure is a little rough…

Hi File Save,Thanks for taking me under your wing so to speak. You’ve been such a great help as a tutor.

Okay, I’ve created the script library but… I don’t know where the sub routine is placed. Is it in the initialized section of the scriptlibrary?

What type of entries need to be placed in the Declarations section? Does anything specific go under options?

Thanks,

Angie

Subject: RE: Input validation failure is a little rough…

I’m here, so I might as well. Not trying to usurp anyone’s position…

Go to the bottom of any area in the library (after any text). As soon as you type Sub SubName(input as Type) and hit return, a new section is created in the script library (or in any event code, for that matter) for that sub. Same goes for functions.

Subject: RE: Input validation failure is a little rough…

Stan,

You are never, ever a usurper. I have learned a great deal from your posts and even your responses to some of my posts. Pretty good for a Canuck:-)

In a thread further down the page, I bordered on testy because Norman did not realize that I had been working with Angie for a while now and had jumped in critiquing her code (actually code I worked on with her in a very deliberate manner for learning purposes) without knowing how we had gotten to the point she was at (you know walking brfore you run) or knowing the history of her requirements.

Thanks!

Subject: RE: Input validation failure is a little rough…

Thanks FileSave, that explains your overwhelmingly negative reactions to my suggestions, which stunned me quite a bit.

A future suggestion, it may have helped for you to have explained that in the correct thread and it might have been turned into a situation that actually helped Angie as opposed to you having to write the code for her.

Just a suggestion

Subject: RE: Input validation failure is a little rough…

Hey Norman,

I hear what you are saying. I do not see this as a code writing exercise, but in the case of Angie, she was a person that was making best efforts to write her code and often times it is difficult to go back and forth in a forum with tips, so in this case I gave her sample code to go from. I am much more likely to do this with a person in the forum who is making an effort as opposed to the many people who post saying “I need to do this, so give me some code” without making an effort themselves.

As she had never scripted and I keenly felt her pain having been there myself (and still find myself at times), and I had learned a great deal from two people I consider to be the best at what they do (Chris Maio, in independent instructor, and Sal Mazzotta, a Senior Architect with IBM Software Services for Lotus), I wanted to walk her through a process that was iterative and provided underlying concepts. Again, this is very hard to do in a forum such as this given her problems.

I responded the way I did (apologize if it seemed knee jerk) as I felt you had jumped in without having the full context of Angie’s problems and the requirements that had been put on her internally, which we had gone round and round on in previous threads. (And I felt my coding process, which was being done deliberately with a purpose, had been attacked by you:-) )

Also, when I ask someone to see their code, it is so I can fully see their context because many, many times the problem is not in the code itself (which they may or may not have posted), but in something else outside the code that is causing the problem. I remember one case where a person was having fits with documents showing correctly in one view and not others. They spent hours rebuilding forms and views, rebuilding their server (I kid you not), etc. When I got the DB, I quickly found out that the entire problem was the result of one column attribute in one view.

Peace!

Subject: RE: Input validation failure is a little rough…

With the current instructions I’ve created the subroutine but… there were no instructions to put in anything. Is that true or did I miss something?

I have followed your instructions and have coded the recommended QuerySave code.

Thanks,

Sub documentSubmit(ws As NotesUIWorkspace, docCurrent As NotesDocument)

End Sub

Subject: RE: Input validation failure is a little rough…

Hey Guys,My goal is to not just copy your code but to really learn from it.

Please translate…

msg + | → Field2 | & Chr(10)

What does the pipe symbol and arrow mean and are they literally included in the code or is this symbolic only? Also Chr(10) what’s this used for?

Thanks so much!!!

Subject: RE: Input validation failure is a little rough…

The pipe is an alternative to quotation marks. Because of the potential for problems with quotation marks, most scripters use the alternatives || or {} instead. Personally, i don’t like pipes because you can’t tell where a string begins or ends in a third-party IDE or a plain-text transposition.

The Field1 and Field2 parts are symbolic, but the arrow is literal. Because you aren’t setting field focus on failure, you nee to give the user a clear indication of what needs to be fixed. What you are trying to get in the end is a messagebox like this:

Subject: Oh, and Chr$(10) is the line break (was Re: Input validation…)

Subject: RE: Input validation failure is a little rough…

Thanks Stan,I’ve got it now!

Subject: Input validation failure is a little rough…

Angie,

As we discussed earlier, this code needs to be moved to a script library and the querysave should call the script linrary subroutine after validation has been passed.

It can also be moved to the postsave event. (where I felt it belong way back when if you rememeber).

Subject: Input validation failure is a little rough…

Angie,

would it help to put the code in the PostSave event?

Then you know the document has successfully validated and has been saved.

In the Query Save event, there is the likelyhood that validation hasn’t yet occurred and some fields may be empty.

Hope that helps … John Kvalheim

Subject: Special thanks to everyone! Especially File Save

Thanks everyone for your help this afternoon, especially File Save. You’ve led me through the writing of my first LotusScript library!

All of your explanations as to how and more importantly why are invaluable to me. Thanks guys, I will learn LotusScript yet!

Subject: one comment

Take the “FIELD Saveoptions” line out of your save button and just create the saveoptions field on the form. This will prevent the “do you wanna save” prompt when closing without hitting the save button.