logo

Experience isn't always everything

It sometimes takes somebody with a fresh outlook to make us "experts" realise that we don't know everything. What we take for granted as knowing they don't presume to know. With this approach they can try things that we would sooner assume is not possible. Last week I got a mail from a somebody who confessed I'm new to Lotus Notes/Domino programming. Nothing strange there, I get lots of mail that starts like that. But then I read the following line:

Instead of using an agent in the webquerysave event, I actually embedded code into the webquerysave event field using the @mailsend function to mail the submitted data back to the user.

This is the point where I was thinking to myself "you've done what!?" and was about to reply without bothering to read the rest of the mail simply telling them it can't be done. Then I started thinking hang on a minute, having never tried doing this how do I know you can't. Not wanting to get egg in my face and embarrass myself in front of a novice I thought I'd have a go myself first.

Turns out you can indeed add @Functions straight in to the WebQuerySave event of a form. This is less surprising when you consider that you can make the agent you run conditional using @If statements like this. Now either it is just me who has missed out on this seemingly obvious fact or this news has been revelationary for the most of us. If it's just me then you may as well stop reading now.

So, what does this mean:

First of all it means exercise caution. Did Iris intend this to be the case? Will it always work and/or is it supported. Why does this kind of thing just not get as far as us the developers. My guess is that this "feature" exists merely as a side-effect of the way in which the WebQuerySave event is implemented.

Secondly it means your life is now a lot easier. Next time somebody requests that a mail is sent every time a document is saved you don't need to brush up your LotusScript or dig out that agent you wrote a while back or try and remember which class DocumentContext is a member of. All you need to do is add this one line function:

@MailSend("Jake Howlett"; "everyone@theworld.com"; "";
"A new document created at " + @Text(@Now);
"Subject of new document = " + NameOfDocsSubjectField
)

Like in Figure 1:

image
Figure 1. @Functions in the WebQuerySave event


Doesn't get much easier than that does it!? You can even do the same in the WebQueryOpen event. Let's pretend all you wanted to do in this agent was set the value of a field. Use this instead:

FIELD Test:=Test;
@If(@IsNewDoc; @SetField("Test";"Fill me in please"); "")

What you do is of course down to you and your requirements but there is no doubt this is going to make life a lot easier for us web developers.



Note: As I mentioned above this is, as far as I know, an undocumented feature. Use it at your own discretion. Also, having not tested it in anything other than version 5.0.6a I can't say with which versions it is possible.

Feedback

  1. Use it to read querystring and set fields

    Hi,

    I use this since 4.6.

    I also use it a lot in webqueryopen to read the Query_string, and set default values for fields with the parameters sent with the URL!!!!

    By using this technique you have all the deault values setting for all your fields in one codeblock, instead of setting the code in each 'deafult value' event of the field itself.

    A lot easier to maintain!!!

  2. Email via function sending to only one person

    This method looks great but I was just getting ready to go to lotusscript for my mail agent similar to the sample in this discussion. The SendTo field on my form in multi-value and computed. When the Sendto shows two names in the field but when the message goes out, it seems to only pick up the first items. It's as if I was mailing to the [0] value. Got any ideas?

  3. about @mailsend

    HI, I have used a feedback form ..and i want that on submit the feedback form contents will appera in my mailbox...can i do this n yeah the submit button is a picture and it is created as hotpot rectangle Any help wud be apprecietaed Thanx priyanka

Your Comments

Name:
E-mail:
(optional)
Website:
(optional)
Comment:



Navigate other articles in the category "Forms"

« Previous Article Next Article »
Ideas on reporting form validation errors   Can you give me a hint?

About This Article

Author: Jake Howlett
Category: Forms
Hat Tip: Nina Manns
Keywords: none

Options

Feedback
Print Friendly

Let's Get Social


About This Website

CodeStore is all about web development. Concentrating on Lotus Domino, ASP.NET, Flex, SharePoint and all things internet.

Your host is Jake Howlett who runs his own web development company called Rockall Design and is always on the lookout for new and interesting work to do.

You can find me on Twitter and on Linked In.

Read more about this site »