Process multiple field edits at one time

Process multiple field edits at one time

If your users find it annoying to receive multiple field-error warnings when trying to save a Lotus Notes document, this LotusScript code will allow you to show all the problems or missing fields in a single pop-up.

Just place the code below in the QuerySave event of your form. I prefer to order my checks starting with the fields at the bottom of the form and work my way backwards to the top. That way, the final message shows the errors in order, and can place the cursor in the first field on the screen that has a problem.


Dim workspace As New NotesUIWorkspace
 Dim uidoc As NotesUIDocument
 Set uidoc = workspace.CurrentDocument
 Dim item As NotesItem
 Dim holder, holder2 As String
 Dim Missing, Jumpto  As String
 
 '==============================
 
 Jumpto = ""          
' field where cursor will end up

 '=============================
 ' sample code to make sure that at least one of two fields is filled in
 '=============================
 
 holder = Trim$(source.FieldGetText("USMail"))      
' get value of field 1
 holder2 = Trim$(source.FieldGetText("eMail"))      
' get value of field 2
 If (holder1 = "") Then         
' if field 1 is empty
  If (holder2 = "") Then        
' and field 2 is empty
   Jumpto = "USMail"       
' place cursor here
Missing = "Delivery method (Requirements tab)" + Chr(10) + Missing 
' warning message for final pop-up (plus which tab the field is on)
  End If
 End If
 
 '=============================
 ' sample code to make sure that

    Requires Free Membership to View

    Register today to access targeted resources from our editorial writers and independent industry experts focused on Lotus Domino, Notes, Workplace and other related technologies.

    By submitting your registration information to SearchDomino.com you agree to receive email communications from TechTarget and TechTarget partners. We encourage you to read our Privacy Policy which contains important disclosures about how we collect and use your registration and other information. If you reside outside of the United States, by submitting this registration information you consent to having your personal data transferred to and processed in the United States. Your use of SearchDomino.com is governed by our Terms of Use. You may contact us at webmaster@TechTarget.com.

an optional field meets required values '============================= holder = Trim$(source.FieldGetText("MailNo")) ' get value of field If Not(holder = "") Then ' if a value exists If Not(holder = "NA") Then ' and it's not NA If Not(Isnumeric(holder)) Then ' if not numeric Jumpto = "MailNo" ' place cursor here Missing = "Mail number: numeric or NA (Requirements tab)" + Chr(10) + Missing Elseif (Len(holder) > 4) Then ' number, but greater than acceptable length Jumpto = "MailNo" ' place cursor here Missing = "Mail number: 4 digits (Requirements tab)" + Chr(10) + Missing End If End If End If '============================= ' sample code to make sure that a required field is present, and that the length is acceptable '============================= holder = source.FieldGetText("BlockStartRequest") ' get value of field If (holder = "") Then ' if missing Jumpto = "BlockStartRequest" ' place cursor here Missing = "Block requested by" + Chr(10) + Missing ' warning message for pop-up Elseif (Len(holder) < 4) Then ' present, but less than acceptable length Jumpto = "BlockStartRequest" ' place cursor here Missing = "Block requested by (name, not initials)" + Chr(10) + Missing ' warning message for pop-up (and an indicator about how to fix it) End If '============================= ' sample code to make sure that a required field is present '============================= If ( source.FieldGetText( "BlockCategory" ) = "" ) Then ' if field value is missing (don't bother with holder field if only doing one check) Jumpto = "BlockCategory" ' place cursor here Missing = "Category" + Chr(10) + Missing ' warning message for pop-up End If '============================= ' we've scanned all relevant fields - if we have any issues, notify them with a single message box '============================= If Not(Missing = "") Then ' if we have a problem, notifiy the user Messagebox "Please enter/correct the following field(s):" + Chr(10) + Chr(10) + Missing, 0 + 48,"Required information" Call source.GotoField( Jumpto ) ' jump to the last field we found with an error Continue = False ' and stop the QuerySave from completing End If

Do you have comments on this tip? Let us know.

This tip was submitted to the SearchDomino.com tip library by member Dave Fairchild. Please let others know how useful it is via the rating scale below. Do you have a useful Lotus Notes, Domino, Workplace or WebSphere tip or code snippet to share? Submit it to our monthly tip contest and you could win a prize.

This was first published in May 2006

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.