logo

Conditional WebQuerySave agents

We all know that you can run agents when a web page gets submitted, by using the WebQuerySave event of a form.

Image

So, if your form is called resource, and you want to run an agent called "SaveResource" when it is submitted you enter the following:

Image

However, notice that in the design pane shown it says "Enter a formula that runs an agent." This basically means that you can create any kind of conditional formula as long as it results in an @Command([ToolsRunMacro];"...") call. For example, say you wanted to only run the query save agent only if the field called "RunAgent" was set to "1". Use the following:

Image

The possibilities are almost endless. You could use the QuerySave agent only if it a Tuesday:

@If(@WeekDay=3;
@Command([ToolsRunMacro]; "(TuesdaySave)");
@Command([ToolsRunMacro]; "(OtherdaySave)")
)


You get the idea right ?

Note: Agents that run on the web have to be set to:
Run - Manually from agents list
On - Run once (@Commands may be used)

Also, although you name agents without the parentheses i.e ResourceSave and not (ResourceSave), Notes uses these when it references them and so you need to use them in your ToolsRunMacro @command.


Feedback

  1. Multiple WebQuerySave agents

    You can also execute multiple webquerysave/open agents @Command([ToolsRunMacro]; "(TuesdaySave)"); @Command([ToolsRunMacro]; "(OtherdaySave)")

  2. you can also make it dynamic

    I found that you can make the agent execution dynamic by assigning it a value from a field. @Command([ToolsRunMacro];<fieldname>)

    1. Re: you can also make it dynamic

      That's the way I do it. I set it equal to a field name and then I assign the field a value with JavaScript just prior to submitting. While you don't have to do this everytime, it works really nicely for work flow applications when you want to trigger different agents based on the condition of the document.

    2. Re: you can also make it dynamic

      Some one can help me in detail how I can use @Command([ToolsRunMacro];<fieldname>) ??

      Thanks in advance,

Your Comments

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



Navigate other articles in the category "Agents"

« Previous Article Next Article »
Debugging LotusScript Agents   Passing arguments to a LotusScript agent

About This Article

Author: Jake Howlett
Category: Agents
Keywords: Condional; Agent;

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 »