Web Agent Unable to Get Field Values

I have an agent that works when called using @command([toolsrunmarco]). But I since I need to add the prompt function of javascript, which primary use is to get comment from user before clicking process button (sending and changins of doc status) I instead run it on Web Common JavaScript with

location.href=“http://Host/Database/AgentName?OpenAgent”

The “Agent Done” is displayed but the agent does not work at all. I tried displaying the field value of some fields in the server console but it gets no value.

Can someone please tell me where I went wrong?

Also, since formula languange is working. I am also trying to call the javascript prompt function from the formula language.

Any idea if this works?

Would appreciate to get solution on this. Thanks so much!

Subject: Web Agent Unable to Get Field Values

Hi,

I presume that you use the “DocumenContext” property…

From an open document, when you launch an agent with JS the source of “DocumenContext” is NOT the current document but the agent himself…

You must pass ID of doc in URL to get it in agent… something like this :

URL :

“http://Host/Database/AgentName?OpenAgent&IDDoc=UNIDOfDoc”

Agent :

…

dim doc as NotesDocument

dim realDoc As Notes

dim unid as String

’ Look in Designer help for CGI variable “Query_String_Decoded”

set doc = session.DocumentContext

unid = Right(doc.Query_String_Decoded(0),32)

’ Get document

set realDoc = db.GetDocumentByID(unid )

HTH

Thierry

Subject: RE: Web Agent Unable to Get Field Values

Hi Thierry,

Thanks for your help.

Yes, I am using DocumentContext property.

Your solution will definitely help on my documents which were already saved. How about on new docs?

I am actually displaying the comment of the users from beggining to end. =)

Subject: RE: Web Agent Unable to Get Field Values

with new docs, no way, except if you saved and re-open your document but why not use only -if you can- Javascript (instead an agent) to get the comment and change or not a field value before to save the document…

Example (Conditionnal submit) :

var comment = document.getelementById(‘FieldID’).value

var conf = confirm(comment +'\rDo you want submit this comment?)

if (conf) {

document.getelementById(‘FieldIDToChange’).value =‘approve’

document.forms[0].submit(0)

} else {

return false;

}