Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Validating Fields on a form by button

Status
Not open for further replies.

rridsdale

Technical User
Sep 20, 2006
4
US
I have a form that users will be filling out. It is a long form so I would like them to be able to save and come back to the form. However, prior to submitting the completed form I need to have all of the fields validated that they made choices in each field. Everything I have found will force a validation on each save.

Thanks for you help.
RR
 
What you describe is entirely possible, but what is the question ?

Pascal.
 
Could you show me sample of code that I would use on a button to check the validation of multiple fields in a form.
 
To validate a field you need a test :
Code:
@if(recipientname = "";@return("Please indicate the name(s) of the recipient(s)");1)
If you wish to validate several fields, you need to keep track of them :
Code:
chkOne := @if(deliveryDate="";1;0);
chkTwo := @if(Quantity=0;1;0);
validation := chkOne + chkTwo;
@if(validation = 0;@setfield(validCheck;"1";@return("Please review and fill in the mandatory fields");
@PostedCommand([FileSave]);
@PostedCommand([FileCloseWindow])
In the last example, the code check two fields for valid data. If all fields are good then no errors are raised, the validCheck field is set to True and the document is saved and closed. If an error is raised, a message is returned to the user and the code aborts before getting to the save and close part.

The validCheck field is the hinge that ensures that the user cannot save manually. By setting it to False ("0") initially, and by including the necessary code in the QuerySave event of the form, you tell Notes to not save the document as long as the validations have not been performed.

Once the user clicks on the button after having filled in all fields, the button sets the validCheck field to "1" (or True) which ensure that the QuerySave code will indeed find that it can proceed with saving, which then makes everything appear normal to the user.

The QuerySave event would look like this :
Code:
@if(validCheck="1";@True;@False)

This is one method. I'm sure you can find another.

Pascal.
 
I am so new to this...I hate to sound like a complete idiot but I am not able to get this to work. I have created the validCheck field and set the default to "0".

I also added @If(validCheck="1";True;False) to the QuerySave.

I copied and pasted the code directly from your post into my button and replaced the fields being checked with two fields in my form. I was getting an error that there are too many arguments for @Function. Process of elimination narrowed it down to this line. @If(validation = 0;@SetField(validCheck;"1";@Return("Please review and fill in the mandatory fields");
Not sure if it was correct I tried adding a ) after validCheck;"1" then another at the end of the string. What appears to be happening in the form is that the entered text is being removed then saved.

------------

Last night in my desperation to get this out, in another copy of the form I added lotus script to the querysave to check all the required fields I was able to make it check the fields and return messages...however, this is not going to work because the person creating the document is not the same person that will be filling it out and the fields are required to save. Is there a way in lotus script to say if the user in assigned a certain Role the requirments would be skipped?

Thank you so much for your help!!
 
Don't worry about being inexperienced - everyone is when they start. Count yourself lucky that TekTips exists, along with near-ubiquitous Internet access. When I started, I could only ask my collegues - and only when they were around ! :)

I also added @If(validCheck="1";True;False) to the QuerySave.
Are you sure you typed it in as above ? If so, you have an error, it should be :
Code:
@If(validCheck="1";[b]@[/b]True;[b]@[/b]False)
That might account for one issue.

As for skipping requirements, you can do one of two things : code a check in Script, or include another field and do the check in Formula. I admit that I prefer doing the latter.

In Script, you can obviously do just about anything, but it is often more complicated than when a Formula exists for the same thing. For roles, a formula does exist : @UserRoles.

Therefor, the easiest thing to do is create a RoleCheck field with a formula that will verify if the current user has the assigned role or not. Make it a ComputedForDisplay field, and enter the formula :
Code:
@if(@contains(@UserRoles;"[i]<name_of_role>[/i]");"Y";"N")
This code will check if the user has the named role, and if he does, the field will contain "Y".
Your ValidCheck field then needs to be changed in order to take into account the feature you wish to add :
Code:
@if(RoleCheck="Y";@true;@if(ValidCheck="1";@true;@false))
Be wary of another thing : when you assign a Role in the ACl, you get 15 chars to name it, but when you check the role in the list, you see it has square brackets around the name you just assigned. Those square brackets ARE part of the name, therefor you need to code for "[name_of_role]" when you refer to it in a Formula or Script code.

Pascal.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top