Web - Pass Values

Hi,

Is it possible to pass values from one webform into another using an agent? - I have tried addding “&fieldname=test” in the URL and then using @URLQUERYSTRING(fieldname) in the default value of the field i want the value to be in…but it just isnt playing ball!

Anyone have any suggestions?

Thanks

F1H

Subject: Web - Pass Values

Taken from Lotus Domino Designer 7 Help ----

Agents cannot run in a browser. They can be activated from a browser but run on the Domino server containing the agent.

Setting up a Web agent

Using the Agent Properties box, do the following:

Check the “Shared” option when you create the agent.

Set the agent trigger to “On event” and either “Agent list selection” or “Action menu selection.”

Set the agent target to either:

“None” for agents that work on the current document such as those launched from WebQueryOpen or WebQueryClose, or a form action or hotspot that works on fields in the current document.

“All documents in database” for agents that work on existing documents such as those launched from the OpenAgent URL or a view action. The actual documents processed depend on the agent code, for example, the SELECT statement in a formula or the UnprocessedDocuments property in LotusScript.

Check “Run as web user” on the Security tab to run the agent using the browser login name. Otherwise the agent runs with the rights of the agent signer.

Activating a Web agent

You can activate agents from a browser in two ways:

OpenAgent URL command. Entering the name of an agent wherever URLs are allowed launches the agent.

RunAgent @command or ToolsRunMacro @command. You can use these @commands, which are equivalent, in an action, a hotspot action, a hotspot button, the WebQueryOpen event, or the WebQuerySave event.

The name of a hidden agent (for example, if the trigger is “Agent list selection”) must include the parentheses when RunAgent or ToolsRunMacro launches the agent. The parentheses are optional when the OpenAgent URL command launches the agent. The OpenAgent URL requires conversion of special characters for Web use; for example, a space must be specified as + (plus sign) or %20.

Two form events work for Web processing:

WebQueryOpen occurs before Lotus Domino converts the document being opened to HTML and sends it to the browser. You can change initial field values and do other pre-processing.

WebQuerySave occurs before a Web document is saved. You can change final field values and do other post-processing.

To prevent the document from being saved, the document must contain a text field named SaveOptions with “0” as its value.

Note The SaveOptions field must be an existing field, the value of which the Web agent changes to “0”. If the Web agent creates this field, the document will be saved regardless of the value.

LotusScript and Java in Web agents

A Web agent can be written in LotusScript or Java, as well as formula or simple actions.

An agent is the only context in which a Web application can use LotusScript. Anything that runs in the browser, such as an action, hotspot action, hotspot button, or event, cannot contain LotusScript. LotusScript agents activated from the Web cannot use any of the classes NotesTimer, NotesUIDatabase, NotesUIDocument, NotesUIView, or NotesUIWorkspace.

You can write HTML to the browser by putting it in print statements. Domino accumulates print statements and creates a page with their contents after the agent runs.

To display a new page after an agent runs, put one print statement at the end of the code containing the page’s URL in brackets. You can start the URL with a slash and the name of the database to designate an element in the current database.

In Java, you must get a PrintWriter object with AgentBase.getAgentOutput and use this object to write to the browser.

The available context depends on how the agent is started:

If the RunAgent or ToolsRunMacro @command starts the agent, DocumentContext or getDocumentContext gets an object representing the current document.

If the OpenAgent URL command starts an agent, there is no current document, but DocumentContext and getDocumentContext return a special NotesDocument or Document object containing the values of the CGI variables supported by Lotus Domino. In the case of RunAgent or ToolsRunMacro, CGI values are available but not automatically. The form backing up the current document must contain a field named after each desired CGI variable.

The OpenAgent URL command passes arguments at the end of the URL string delineated by ampersands. For example:

http://host/database/view/OpenView&Start=1&Count=20

In LotusScript and Java agents, you can get the arguments by parsing the Query_String item in the document returned by DocumentContext or getDocumentContext. Query_String contains the entire URL command that started the agent.

Subject: RE: Web - Pass Values

Thank you soo much for this brilliant and extremely helpful post Gwen.

Subject: Web - Pass Values

Yes - but you have to get the value out once it’s been posted. What are you using for agent? LotusScript or Java?

Subject: RE: Web - Pass Values

Hi,

Thanks for your very fast responses…I will re-configure the agent properties and ensure it is setup as a web agent (assuming it can with ver.6.5?)

I am using LotusScript for my agent.

Thanks

F1H

Subject: RE: Web - Pass Values

I have checked the properties of the agent and they were all set correctly.

When i Print the URL in the agent it opens the desired for just fine…but its passing the values that seems to be my problem.

Any further suggestions?

F1H

Subject: RE: Web - Pass Values

Ok now take a look at the examples in the designer help - in most cases you can the values out of the form in the agent via the DocumentContext.

once there getting the values carries on just as normal.

Subject: RE: Web - Pass Values

I have had a look at the examples and whatever i try…its not working.

I have stored the files into variables in the agent :

strProjName = doc.Project(0)



strPath = ReplaceSubstring(db.FilePath, "\", "/")

strURL = "/" + strPath + "/ProjMatSetup?OpenForm&Project=strProjName"

Print "[" + strURL + "]"

Where am i going wrong?

Thanks

F1H

Subject: RE: Web - Pass Values

I haven’t read that you have done any debugging. Try typing the URL directly into your browser. Does the agent run? Is there an error in the server log.nsf? What are the values of the fields? Can you parse the query_string?

Once you are sure that the agent is parsing the arguments from the QS, then figure out whether your code above is generating a good URL. Use a generous number of MsgBox statements so you can tell is STRPATH and STRURL and other variables contain what you think they contain.

Try something like this:

Sub Initialize

’ this agent called with “…GrpMems?openagent&groupname&timestamp”

Dim sess As New NotesSession

Dim nabDB As NotesDatabase

Dim gDoc As NotesDocument

Dim curDoc As NotesDocument

Dim gView As NotesView

Dim queryString As String

Dim gName As String

Dim memItem As NotesItem

Dim mName As NotesName



On Error Goto handler



Print {<html><head><title>Group Membership</title></head>}

Print {<BODY TEXT="000000" BGCOLOR="ffffff">}

Print {<hr>}



Set nabDB = sess.GetDatabase( sess.CurrentDatabase.server, "names.nsf", False ) ' server address book



Set curDoc = sess.DocumentContext ' current web page



queryString$ = curDoc.Query_String(0) ' right of the & will be the groupname and timestamp

gName$ = 	ReplaceSubString( Strright( queryString$, "&" ), "%20"," " ) ' put in spaces too

' x Msgbox "GrpMems-gName$=" & gName$ ' zzz

gName$ = 	Strleftback( gName$, "&" ) ' get everything left of the timestamp

' x Msgbox "GrpMems-gName$=" & gName$ ' zzz

If gName$ = "" Then' name of group to show from the URL

	Print "GrpMems-error - no Group specified on the query_string:<b>" & queryString$ & "</b>"

	Goto closeHTML

End If

Subject: RE: Web - Pass Values

Thanks for your post. I have managed to get it to pass values into the webform, but my next problem is that 3 of the fields are multi-value, does anyone have any suggestions as to how to transfer all the values in?

Thanks

F1H

Subject: RE: Web - Pass Values

Better solution – don’t pass any values. Use session.DocumentContext (or other method) to get a handle on the document which initiates the transaction. Then you can read the fields/values straight from the doc.(search this forum or on-line help)

Subject: RE: Web - Pass Values

Hi,

Thanks for your post…- I am using DocumentContext, but i am trying to pass the values from a Dialog List…is this possible?

Here is my code :

Dim session As New NotesSession

Dim db As NotesDatabase

Dim doc As NotesDocument

Dim ProjDoc As NotesDocument

Dim strPath As String

Dim strURL As String

Dim strDocOwner As String

Dim strAuthors As String

Dim strReaders As String

Dim strSections As String

Dim strAtt As String



Set db = session.CurrentDatabase

Set doc = session.DocumentContext



strDocOwner = doc.DocumentOwner(0)

strAuthors = doc.AuthorsAU(0) & "; " & doc.AuthorsAU(1)

strReaders = doc.Readers(0) 

strSections = doc.Sections(0)



strPath = ReplaceSubstring(db.FilePath, "\", "/")

strURL = "/" + strPath + "/ProjMatSetup?OpenForm&DocumentOwner=" & strDocOwner & "&AuthorsAU=" & strAuthors & "&Sections=" & strSections

Print "[" + strURL + "]"

End Sub

Thanks

F1H