Calculate number of names email is being sent to when user hits the esc key

I have the requirement to check the number of names in the to, cc, and bcc fields to see if the number is greater than 50. If it is, I am supposed to show a yes/no prompt box that will ask them if they meant to send it to that many people. I have the code for the send button that looks like the following:

MEMO_SEND:=“1024”;

total_list := @Trim(EnterSendTo : EnterCopyTo : EnterBlindCopyTo);

number_of_sendees := 0;

num_names := @Elements(total_list);

@For(n:= 1; n<= num_names; n:= n + 1; temp_name := @If(n = 1; @Subset(total_list; 1); n = num_names; @Subset(total_list; -1); @Subset(@Subset(total_list; n); -1));

temp_lookup := @DbLookup("": "NoCache";  "852560A0:00505DB4"; "($VIMGroups)"; temp_name; "Members");

@If(!@IsError(temp_lookup); @Set(“number_of_sendees”; number_of_sendees + @Elements(temp_lookup)); @Set(“number_of_sendees”; number_of_sendees + 1)));

@If(number_of_sendees > 50; @Do(

	answer := @Prompt([YesNo]; "Send to Large Audience?"; "Please be advised, you are sending this email to a large audience.  Continue?");

	@If(answer != 1; @Return(""); ""));"");

FIELD ActionInProgress:=MEMO_SEND;

@If(@Command([FileSave]);@Command([FileCloseWindow]);@Return(“”))

Now…here is the tricky part, I have to make sure that check runs if the user hits the esc key (we have the option Present Mail Send Dialog on).

Any idea of how to run the code on the escape key command?

Thanks in advance.

Subject: Maybe…

I have never used this, perhaps it might help you or at least provide an idea of what might be…

Forcing a user to click the Exit Button to close a form ( i.e “escaping” not allowed")

There are times when you do not want a user to be able to close a form by choosing escape or selecting “file/close” from the menu.

In my case I wanted the response document to update totals on the main document before exiting.

This shows one way to force a user to close a form by taking an action you specify. (for example, Clicking an “Update and exit” button.)


My form is in editmode when the user opens it.

If your form is not in edit mode initially, you may want to move the “postopen” code to the “postmodechange” event.

On the form I have a hidden editable field called “EscapeCheck” (Could actually have any name)

In the postopen event of the form as soon as the form opens, I set this editable field “EscapeCheck” to the value “NoExit”:


 Dim session As New NotesSession

 Dim db As NotesDatabase

 Set db = session.CurrentDatabase

 

 Call Source.FieldSetText ("EscapeCheck","NoExit")

The Input Validation event for the EscapeCheck field is coded as…

@If(EscapeCheck=“NoExit”;@Failure(“Please click 'Update and Exit' to Close”);@Success)


In my case, this validation is only done when the document is being saved.

If, in your case, you “refresh” the document some time before exiting you may need to add an @IsDocBeingSaved condition to this formula.

When the user tries to escape from the form, he gets the “Please click ‘Update and Exit’ to close” message and the form does not close.

Final piece is to include the following code in the click event of an “Update and Exit” button.

 Dim workspace As New NotesUIWorkspace

 Dim uidoc As NotesUIDocument

 Set uidoc= workspace.CurrentDocument

 uidoc.editmode = True

 Call uidoc.FieldSetText ("EscapeCheck","OK")

 Call uidoc.Save

This sets the EscapeCheck field to a value other than NoExit and allows the form to close.

(You can add any other updating code your need to this button.)