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(""))

USER FEEDBACK TO THIS TIP

 

  • 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

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

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.