Home > Domino Tips > Developer > LotusScript > Process multiple field edits at one time
Domino Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

LOTUSSCRIPT

Process multiple field edits at one time


Dave Fairchild
05.23.2006
Rating: -3.75- (out of 5)


Lotus Notes and Domino tips, tutorials and how-to articles
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


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 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.

Rate this Tip
To rate tips, you must be a member of SearchDomino.com.
Register now to start rating these tips. Log in if you are already a member.


Submit a Tip




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google



RELATED CONTENT
LotusScript
LotusScript agent parses ACL to Microsoft Notepad
LotusScript finds the first occurrence of a string from the right
Clear Recent Contacts view and prevent repopulation in Lotus Notes 8.x
Search Microsoft Active Directory with LotusScript
Three steps to trap and handle save conflicts with LotusScript
Troubleshoot agents by displaying LotusScript variables online
LotusScript sorts lists alphabetically
LotusScript code rebuilds corrupted busytime.nsf file
Soft-code item names to facilitate LotusScript management
LotusScript agent automates selective mail file replication

LotusScript
LotusScript agent parses ACL to Microsoft Notepad
LotusScript finds the first occurrence of a string from the right
Clear Recent Contacts view and prevent repopulation in Lotus Notes 8.x
Search Microsoft Active Directory with LotusScript
Three steps to trap and handle save conflicts with LotusScript
Troubleshoot agents by displaying LotusScript variables online
LotusScript sorts lists alphabetically
Run or restart Notes/Domino agents via text messages
LotusScript code rebuilds corrupted busytime.nsf file
Soft-code item names to facilitate LotusScript management

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

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.



Domino & Lotus Notes Security Solutions: Authentication, Antispam, Encryption and Antivirus
HomeTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersDomino IT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 1999 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts