Experience isn't always everything
Jake Howlett, 27 August 2001
Category: Forms; Keywords:
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:
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.
Copyright © 2000 - 2024 Jake Howlett of Rockall Design ltd. This article was printed from codestore.net