Home > Ask the Domino Experts > Domino Designer Questions & Answers > Is LotusScript needed to validate fields on form?
Ask The Domino Expert: Questions & Answers
EMAIL THIS

Is LotusScript needed to validate fields on form?

Brad Balassaitis EXPERT RESPONSE FROM: Brad Balassaitis

Pose a Question
Other Domino Categories
Meet all Domino Experts
Become an Expert for this site


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


>
QUESTION POSED ON: 12 August 2005
Brad, I am an old Lotus Notes developer (hacker) and I have created a few databases over the years. However I have not learned LotusScript yet, and I think I need to use it for this problem.

I have a form with a field named ALLOY. I need to validate this field using the logic below, if it's empty complain, and if the drop down box in said field ends up selecting NOT LISTED, also complain. Now, the command below works fine. . .

@If(@Length(ALLOY) <1;"MISSING BASE ALLOY";
 ALLOY= "NOT LISTED";
"MUST SEE MARY LOU FOR THIS QUOTE";
 @Success)

. . .but not when you click out of the field -- it only validates when you save the document. I need it to validate once you click out of the field. I thought a uidoc.refresh would do the trick (my only LotusScript knowledge) on the exit event --and it did -- but unfortunately I have several other fields on this form that also need to be validated, and once you click out of the ALLOY field and the refresh happens it complains about ALL the other empty fields on the form. So I was told I needed to take this command and put it in the exit event of the ALLOY field using LotusScript. I was also told that the syntax would look something like this:

Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Set uidoc = workspace.CurrentDocument
if (uidoc.fieldgettext <1 then
Messagebox( uidoc.FieldGetText
( "MISSING BASE ALLOY" ) )else if 
(uidoc.fieldgettext =NOT LISTED
then Messagebox( uidoc.FieldGetText
( "MUST SEE MARY LOU FOR THIS QUOTE" ) ) 
goto uidoc.field (ALLOY)

However as you can see I have totally messed this up and it doesn't work. Based on what I am trying to do -- validate several fields on a form at the point when you exit (exit event of each field) said field -- what should my LotusScript look like?


>
There are a few issues here. First, you cannot compare a field value to 1. One is text and the other is numeric, so that may cause a problem. You need to use the Length function to check the size of the field value in order to compare it to 1. It's actually a bit cleaner to just check whether the field value is an empty string.

The other main issue is that you need to specify the field name with the uidoc.FieldGetText call. That function is designed to use the current field if no field name is specified, but by the time you exit the field, the current field could be the next field on the form (if you tabbed out of the field)!

Next, you have not properly closed the parentheses around the second condition (else if…). There are also issues with improper function calls, missing quotes around strings, and you also need an End If statement to close the block.

The last few lines should look more like this:

 If (uidoc.fieldgettext("ALLOY") = "") Then
  Messagebox ("MISSING BASE ALLOY")
  Call uidoc.GoToField ("ALLOY")
 Elseif (uidoc.fieldgettext("ALLOY") =
 "NOT LISTED") Then 
  Messagebox("MUST SEE MARY 
LOU FOR THIS QUOTE") 
  Call uidoc.GoToField ("ALLOY")
 End If

Do you have comments on this Ask the Expert question and response? Let us know.


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



RELATED CONTENT
Domino Designer
Resolve Notes 8 migration error: 'Database has not been opened yet'
Lotus Notes access error: 'database is not opened yet'
Stop response documents from showing in a Lotus Notes form
Set a value in a field existing in another Lotus Notes database
Create an automatic scheduled view export in Excel
Display Lotus Notes fields as separate entries in one column
Creating custom Lotus Notes Domino login forms
Using LotusScript to retrieve names of fields on a Lotus Notes form
Importing data from Microsoft Excel to a Lotus Notes form
Error creating product object

LotusScript
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
LotusScript agent automates selective mail file replication

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



Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
Browse our Expert Advice



Lotus Notes Domino on Blackberry and mobile devices
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