You Can View User Feedback To This Tip
I hardly ever see the @IsValid function used in actions that try to Save and Close a document.
Here is the problem:
1. User clicks Save & Close action button.
2. The @Command([FileSave]) tries to save the form. When it fails validation it returns the @Failure message.
3. The user clicks on OK on the failure message and the formula continues with the @Command([FileCloseWindow]) command.
4. This causes a File Save window to appear, if the user clicks yes, the validation is run again.
To Fix this use the following code:
When a user clicks on Save and Close.
@If(@IsValid;@Do(@Command([FileSave]);@Command([FileCloseWindow]));@Return(""))
- The most frequent code for "Save & Close" button is:
@Command ([FileSave]); @Command ([FileCloseWindow]);
But if the document cannot be saved (due to input validation errors), you will get a "save document?" message box caused from the FileCloseWindow command.
This tip suggests using @IsValid to check if the document can be saved. But there is a better way to do this: The @Command([FileSave]) returns a value: @True, when successful, @False otherwise.
So the shortest and best code for an "OK" or "Save & Close" Action is:
@If (@Command([FileSave]);@Command([FileCloseWindow]);"")
Hans-Peter Kuessner
This was first published in May 2002