hcl-bot
September 23, 2009, 3:16am
1
Hi there.
Can anyone confirm with me if the following script works in web browser or not?
Dim var1 As Variant
Dim GetServerTime As NotesDateTime
var1 = Evaluate(|@Now([SERVERTIME]:[LocalTimeonError];@Name ([Cn];@Subset (@DbName ;1)))|)
var2 = Evaluate(|@Name([Cn];@Subset (@DbName ;1))|)
Set GetServerTime = New NotesDateTime(var1(0))
Call doc.ReplaceItemValue(“Field1”, GetServerTime)
The coding works fine when it is run in lotus client. Doesn’t seem to work on web though. I am trying to stamp the server time whenever users trigger the agent either via client or web
Please help.
Thanks!
hcl-bot
September 23, 2009, 3:21am
2
Subject: Evaluate in web agent
Hi,
What does it mean that didn’t work? Is there any error in log.nsf which agent throws?
Do you have handle to doc variable?
Konrad
hcl-bot
September 25, 2009, 2:06am
3
Subject: RE: Evaluate in web agent
Hi Konrad,
Here is an excerpt of the script:
Dim ss As NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim var1 As Variant
Dim GetServerTime As NotesDateTime
Set ss = New NotesSession
Set db = ss.CurrentDatabase
Set doc = ss.DocumentContext
If doc Is Nothing Then Exit Sub
var1 = Evaluate(|@Now([SERVERTIME]:[LocalTimeonError];@Name ([Cn];@Subset (@DbName ;1)))|)
Set GetServerTime = New NotesDateTime(var1(0))
Call doc.ReplaceItemValue(“SupvrReceiveDt”, GetServerTime)
The agent is triggered when user clicks a button and run as background agent. It works fine when triggered in Notes client. On the other hand, the result i get from web browser is null. The Notes automatically set the date/time field to 12:00 am.
Did i miss out something?
hcl-bot
September 25, 2009, 2:16am
4
Subject: RE: Evaluate in web agent
@DbName for agents running on the server returns empty string.Maybe @ServerName solves your problem (check documentation).
Konrad
hcl-bot
September 29, 2009, 2:40am
5
Subject: Evaluate in web agent
It works!! Thanks for the tips Konrad. Thanks everyone.
Have a great week ahead.
hcl-bot
September 23, 2009, 3:29am
6
Subject: Evaluate in web agent
Well, if this works in the Notes client, it means that you don’t correctly get the current document on the Web. It should be fetched using the DocumentContext. Thus, your agent code has to be different on client and on browser.
Thierry Cayla
http://dominoeffects.serveblog.net
hcl-bot
September 25, 2009, 1:46am
7
Subject: RE: Evaluate in web agent
Hi Thierry,
Yup, I used DocumentContext in the agent. And it runs perfectly when I use Now() instead of evaluate:
Call doc.ReplaceItemValue(“Field1”, Now())
However Now() returns the local pc time instead of server time. any other workaround?
hcl-bot
September 23, 2009, 4:42am
8
Subject: RE: Evaluate in web agent
Rightly said. Client Scripting is different from Server-Side Scripting.
Instead of using evaluate, use this when running the agent on server
var1 = now()
var2 = session.CommonUserName
hcl-bot
September 23, 2009, 5:04am
9
Subject: RE: Evaluate in web agent
Hi,
Why Evaluate shouldn’t work on server side? I never hear about it. Is there any info somewhere in documentation?
Konrad
hcl-bot
September 23, 2009, 5:44am
10
Subject: RE: Evaluate in web agent
Evaluate works perfectly well on the server.it meant that the client scripting is different from server side scripting. Sorry for the confusion
why not use easier way to get the result?