Evaluate in web agent

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. :frowning: I am trying to stamp the server time whenever users trigger the agent either via client or web

Please help.

Thanks!

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

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?

Subject: RE: Evaluate in web agent

@DbName for agents running on the server returns empty string.Maybe @ServerName solves your problem (check documentation).

Konrad

Subject: Evaluate in web agent

It works!! Thanks for the tips Konrad. :slight_smile: Thanks everyone.

Have a great week ahead.

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

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?

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

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

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?