Sunday, June 03, 2007

Prohibit users to trigger agents from web

When developing agents, it's easy to forget that every agent can be triggered from web with agentname?OpenAgent URL. Such agent invocation can cause unpredictable results.
To avoid this, developer has these 2 options:
1) Hide agent from web using property "hide design element from: Web browsers"
2) Programmatically find out if the agent is triggered from web and exit

Sub Initialize
ev=Evaluate("@ClientType")
If ev(0)="Web" Then Exit Sub 'Do not run agent if triggered from web
'here goes the rest of the code
'which will be executed in Notes client but not on web
End Sub

3 comments:

Niklas Waller said...

Great tip! Simple but so important. As you say, it's easy to forget.

Anonymous said...

Thanks for the tip, it's a good tip.

Bryan Kuhn said...

nice little tip, I couldn't say I've used it before, but will come in handy as I'm now creating a lot more Web apps.