If user hits ESC keyYes to save my ‘save’ formula doesn’t run

110 pts.
Tags:
Lotus Domino
If user uses the Save button on the Action bar, my code works fine. But if they hit ESC key>Yes to save my 'Save' formula doesn't run. My Save action is validation and sets fields that an Agent will be run on.

Answer Wiki

Thanks. We'll let you know when a new response is added.

I don’t mean for this to come across as rude, but…
Is there a question in there? Are you asking if it’s a bug? Working as designed? Looking for a workaround?

Discuss This Question: 19  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

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
  • Joeydog
    Sorry, my question is how can I force the ESC save option to run my Save(Action)formula code in Lotus Notes Designer version 5.0.12. I will need this to also run on Lotus Notes 6.5.
    110 pointsBadges:
    report
  • CharlesJC
    JoeyDog, You can accomplish your task in several ways. Two come to mind immediately: 1. Add a field that is set to a special value upon clicking the Save action button. In the the QuerySave event test the value of the that field. If it has not been set to the special value, which should only occur when the Save action button is clicked, then set Continue = False and display a message box telling the user to use the save button. 2. Rewrite your validation formula in LotusScript and place it in the QuerySave event. Those are the two methods the come to mind. Hope this helps. CJC
    0 pointsBadges:
    report
  • Stiletto
    Yeah, I basically do what is described in #1 above. If you need specifics, let me know. Another option is to set SaveOptions to "0" which will prevent the user from being asked if they want to save when they hit ESC. In this case, ESC is the same as closing without saving.
    4,050 pointsBadges:
    report
  • Joeydog
    Thanks for your replies! As you can probably tell, I am a Newbie to LN. I tried script in querysave but I think I opened a bigger problem. Formula must be used to calculate the contents of a computed field. I'll need to give more details. I have EffectiveDate(calendar control), ExpiryDate(computed @Adjust(EffectiveDate;0;0;60;0;0;0) and NotificationDate(computed @Adjust(ExpiryDate;0;0;-14;0;0;0) I also have Status field which shows 'Active' or 'Inactive' by comparing the dates to the system date. Therefore, it must be 'computed'. This Status field is needed for reports. I need an agent to run every night and compare the system date to the NotificationDate. If it is equal an email will be sent out. I also need an agent to run every night and use the system date and recalculate and update the Status field. (Question: Will 'computed for display' allow this?) Question: How do I set Save Option to '0' so that ESC will not prompt for Save?
    110 pointsBadges:
    report
  • CharlesJC
    @Formula Language: Field SaveOptions := "0"; LotusScript: (In an event like Postopen) Source.Document.SaveOptions = "0"
    0 pointsBadges:
    report
  • Stiletto
    Regarding the Status field: my recommendation is to make it computed. In fact, I'd make the formula self-referencing, i.e. I'd make the formula simply be Status. Once I was off of R5, I'd change it to @ThisValue. Then, just have the agent set the Status field to whatever you want. That way, you can use the field in a view without it having to compare against the current date for every view entry. If you're sure you'll never need it for anything except that one report, then you could make Status computed for display and get rid of the agent that runs nightly to set it. As for SaveOptions (no intervening space): it is a reserved field that controlls whether the confirmation box pops or not. I usually create a hidden, computed for display, text field called SaveOptions on a form, making the formula simply "0" (numeric zero, not alpha O). Actually, I usually make it a shared field so I can drop it on any form I need.
    4,050 pointsBadges:
    report
  • Joeydog
    Wow,thanks for the replies, what a learning curve this little program has been! I forsee a problem with the AllowSave flag option. What if the user clicks Save then makes more changes, then clicks ESC or X? I have recoded my QuerySave with the same Function code as in Save(click)but now I get a "Attempted to execute nested form events" user pop up. Does SaveOptions work for ESC, clicking X and ctrl S? Isn't there a way I could code for the Yes/No option when ESC is clicked?
    110 pointsBadges:
    report
  • TonyCC
    Hi joeydog, > I forsee a problem with the AllowSave flag option. What if the user clicks Save then makes more changes, then clicks ESC or X? My code sample included a FileCloseWindow, so that scenario is not possible. I guess the button would be better labeled Save & Exit > I have recoded my QuerySave with the same Function code as in Save(click)but now I get a "Attempted to execute nested form events" user pop up. You've probably included a Save in your QuerySave event - never do this! The QuerySave event is triggered just before a document is saved, so doing a save in there will cause a loop. And just for your info, the PostSave event triggers just after a save.
    50 pointsBadges:
    report
  • Joeydog
    Yes, I did copy the Save function along with my calculation code. So that is working. My next problem with my QuerySave is validating. I need several fields to be mandatory FIELD Status := Status; @If( TodayDate >= EffectiveDate & TodayDate
    110 pointsBadges:
    report
  • Stiletto
    I would try inserting an @prompt before and after the line that tests if EffectiveDate is blank. It may be that your code isn't executing all the way through due to a type mismatch. The @prompt lines will help narrow down the problem. As for PDF, try looking at the @functions that start with Attachment, like @attachments and @attachmentnames. RTFs are more complex to test the contents (or lack thereof).
    4,050 pointsBadges:
    report
  • Joeydog
    I have tried @If(@Attachments = 0;@Failure("You must attach document."); @Success )in the QuerySave but it still saves without an attachment.
    110 pointsBadges:
    report
  • CharlesJC
    JoeyDog, RichTextFields are not part of the document until the document has been saved. So, you will have to have special validation for the RTF. Since it needs to occur after the other validation code, you may want to put it in the PostSave event. Also, if you want to execute @Formula language code in the QuerySave and PostSave events you need to use the "Evaluate" LotusScript function. The Evaluate function returns a variant that contains a one-dimensional array. Here is an example of how to use it: 'Start LotusScript Code' Sub Querysave(Source As Notesuidocument, Continue As Variant) Dim lRetVal as Variant On Error goto Erro lRetVal = Evaluate(|@Success|) Continue = lRetVal(0) ExitHere: Exit Sub ErrorHandler: Messagebox "Error: " & Err & Chr(10) & Error,, "QuerySave" Resume ExitHere End Sub 'End LotusScript Example' I hope this helps. CJC
    0 pointsBadges:
    report
  • Joeydog
    I tried this, but still saves with no attachment. Sub Postsave(Source As Notesuidocument) Dim lRetVal As Variant On Error Goto ErrorHandler lRetVal = Evaluate(|@IF(@Attachments = 0 ; @Failure("Please supply attachment") ; @Success) |) Continue = lRetVal(0) 'I also tried this lRetVal = Evaluate(|@Attachments|) ' Continue = lRetVal(1) ExitHere: Exit Sub ErrorHandler: Messagebox "Error: " & Err & Chr(10) & Error,, "PostSave" Resume ExitHere 'End LotusScript Example' End Sub I also read this in another forum: If there are no attachments on the document @Attachments returns 0. As of now notes does not validate richtext fields. I believe you can use @Abstract the field then validate? Validation.... @IF(@Attachments = 0 ; @Failure("Please supply attachment") ; @Success) Does Notes validate richtext fields? Or is my only choice to have a pop up to ask the user if they attached the file and make them Y/N
    110 pointsBadges:
    report
  • CharlesJC
    JoeyDog, I found this information when I Googled "Validating richtext fields in Notes": http://www-128.ibm.com/developerworks/lotus/library/rich-text-field-notes/index.html So, from the site, I created this procedure that will prevent the user from saving without an attachment. (You only need to add the other field validation code to this for it to work) 'Begin sample code Sub Querysave(Source As Notesuidocument, Continue As Variant) On Error Goto ErrorHandler continue = source.Document.HasEmbedded If Not continue Then Messagebox "You have not attached a file.", 48, "Missing Attachment" End If ExitHere: Exit Sub ErrorHandler: Messagebox "Error: " & Err & Chr(10) & Error & " has occurred on line " & Erl, 48, "QuerySave" Resume ExitHere End Sub 'End sample code You can use your @Formula language code with the Evaluate function to do the rest of the validation. Just remember, the return value is in the first element of the array (eg. lRetVal(0)). CJC
    0 pointsBadges:
    report
  • Stiletto
    If you don't like using the Evaluate() call, here's another method: Create a hidden, editable, numeric field called something like MyValidator. Have it default to 0 (numeric zero). In the input validation section put something like... @If( @IsDocBeingRecalculated; @Success; test for expression1 fails; @Failure( "Your message here." ); test for expression2 fails; @Failure( "Your other message here." ); ... @Success )
    4,050 pointsBadges:
    report
  • Joeydog
    Thank you. I think I am in pretty good shape now. I put this in my Status value: FIELD Status := Status; @If( EffectiveDate = "" | ExpiryDate = "";""; @Do(@If(TodayDate >= EffectiveDate & TodayDate
    110 pointsBadges:
    report
  • Stiletto
    In LS, you use pipes instead of quotes whenever your string may contain quotes; you also use pipes if your string needs to contain a CR.
    4,050 pointsBadges:
    report
  • Joeydog
    Thanks, that is very useful to know! What is a CR?
    110 pointsBadges:
    report
  • Stiletto
    CR=carriage return CRLF=carriage return,line feed combination
    4,050 pointsBadges:
    report

Forgot Password

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

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

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

Thanks! We'll email you when relevant content is added and updated.

Following