Solved

Pass a URL string to a webqueryopen agent?

Posted on 2001-08-08
10
1,691 Views
Last Modified: 2013-12-18
Is it possible to pass a variable from a URL into a webqueryopen lotusscript agent?  From there I would like to fill in fields on my webdocument.

I currently pass a URL string to a Query_string field and then perform @dblookups based on the Query_string field value but I'm thinking the WebQueryOpen method might be a lot faster.
0
Comment
Question by:snocross
  • 3
  • 2
  • 2
  • +3
10 Comments
 
LVL 1

Expert Comment

by:pcorreya
ID: 6366453
try the http_refrer cgi variable, I am not sure if it will work with the webqueryopen agent.

Are you try to pass a variable to the webqueryopen agent when you open the document ?
0
 
LVL 4

Expert Comment

by:sloeber
ID: 6367084
The best way to do this is by passing arguments to an agent.
The following code can be used in any agent, in to which lots of parameters get passed and place them all in an list.
The agent starts with the standard declarations.

Sub Initialize
Dim s as new notessession
Dim db as notesdocument
dim doc as notesdocument

set db=s.currentdatabase
set doc = s.documentcontext

which are followed by declaring the list variable that will hold all the arguments.

Dim AgentArgs List as string

and now a call to the subroutine that does all the work (appears futher down) :

Call ExplodeQueryString(doc.Query_String(0), AgentArgs)

This list would normally be used to let the agent go and retrieve the required information, but, for the sake of a demo, lets loop through all the parameters and send their key/value pairs back to the browser:

Forall Args in AgentArgs
Print "Parameter Key: " + Listtag(Args)
Print "Parameter Value : " + Args
End Forall
End Sub

This method of looping through ALL the arguments may not be necessary if you already know the name of the parameter's key.
For example, if a key had the name "country", you could get to its value like this :
Print "Country Code: " + AgentArgs("country")

The Explode QueryString() subroutine :

Private Sub ExplodeQueryString(QueryString as string,AgentArgs List as string)
Dim Args as string
Args = StrRight(QueryString,"OpenAgent&",1)

Dim ArgsList as variant
ArgsList = Evaluate({@Explode("}&Args&{";"&")})

Dim ArgKey as string
Dim ArgValue as string

Forall Arg in ArgsList
ArgKey = StrLeft(Arg,"=")
ArgValue = StrRight(Arg,"=")
AgentArgs(ArgKey) = ArgValue
End Forall
End Sub

Overall, not a very good example, but I'll leave it to you as to how you wish to implement it.

PS : Here's an example of what a URL may look like that is used to call a simular agent :
//www.domain.com/website.nsf/report?OpenAgent&country=be&name=sloeber&date=21%2F11%2F2000

Settings van de agent
Run once from agent list
Run Once(commands may be used)


Greets,
Sloeber
0
 
LVL 5

Author Comment

by:snocross
ID: 6367744
pcoreyya, yes I want to pass the variable to the WebQueryOpen.

Sloeber, that sounds cool but you are sure the QueryString value will be available to the WebQueryOpen event?  I thought the WebQueryOpen event executed before any fields got filled in.
0
 
LVL 4

Accepted Solution

by:
sloeber earned 50 total points
ID: 6367840
Now, you can capture the Query_String value before the WebQueryOpen.
You must set your Query_String field as computed for display and give it the default value Query_String

Greets,
Sloeber

Here's another example may be also interesting for you
Put a computed for display field on the form which is displaying your document, containing the folowing formula:
"{<a href=http:/"+@Subset(@DbName;-1)+"/SetFieldAgent?OpenAgent&key="+@Text(@DocumentUniqueID)+">Set Field</a>}"

The agent with the name "SetFieldAgent" has the folowing code:

Sub Initialize
Dim session As New NotesSession
Dim agentdoc As NotesDocument
Dim doc As NotesDocument
Dim db As Notesdatabase
Set db = session.currentdatabase
Set agentdoc = session.DocumentContext
QueryString$ = agentdoc.Query_String(0)
key$ = Mid$(QueryString$,Instr(QueryString$,"key=") + 4)
Set doc = db.GetDocumentByUNID(key$)
doc.Field1 = "Value"
Call doc.save(True, False)
Print "Field value set"
End Sub


Greets,
Sloeber
0
 
LVL 9

Expert Comment

by:Arunkumar
ID: 6373974
Have a good weekend Guys !
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 10

Expert Comment

by:zvonko
ID: 6376757
Hello Sno,

this boys abowe are giving you good examples to experiment around and I recomad you to do so, but here my two pence: the fields are allways calculated wether you call WebQueryOpen or not. The only speedup is that you have less or no field formulas, but field formula recalculation will allways be done. The slowdown is in starting of WebQueryOpen agant. Formulas are allways faster then LotusScript engine initiation. By the way: WebQueryOpen agent can also be formula agents <|;-) and @dblookups are never cached on web :-(
I do offten place the complete code for an agent into one field formula which checks and recalculates other fields. Even the disadvantage that this field is not reusable like an agent is away with using of a shared field. You remember my @dblookup for LDAP? I am doing this corporate directory lookups, without agent, directly in a field on application forms...

Nice weekend,
zvonko
0
 
LVL 8

Expert Comment

by:Jean Marie Geeraerts
ID: 6379450
Hi sno,
Query_String(0) doesn't refer to a field on the form. It refers to the query string defined in the URL used to call the agent. This is everything behind the "&"- in the URL.
For multiple parameters, I'm guessing you can refer to them by seperating them with an "&" and refer to them as Query_String(1), Query_String(2), etc. (I'm nog 100% sure about this, but I can't test it since my test server appears to be down).
My theory is if you call the agent like :
agentName?OpenAgent&par1=yes&par2=no
Then :
  Query_String(0) = "par1=yes"
  Query_String(1) = "par2=no"
A way to call the agent like that is to put this javascript-code in the onload-event of the form :
location.href="agentNmae?OpenAgent&par1=yes&par2=no"
Anyway, test it and let me know if it's working (my test server as I said is acting up today)
0
 
LVL 5

Author Comment

by:snocross
ID: 6399495
Sloeber, I tried your example but the field just displayed the following...

{<a href=http:/"+@Subset(@DbName;-1)+"/SetFieldAgent?OpenAgent&key="+@Text(@DocumentUniqueID)+">Set Field</a>}

It didn't execute the agent.

Jerrith, your solution looks similar except it's using Javascript... I'll give it a try.

Zvonko, thanks for the interesting info on performance.
0
 
LVL 10

Expert Comment

by:zvonko
ID: 6402001
Hey Snow,

why do you cut'n paste quirly braces? {}

The correct formula is of corse:
"[<a href=http:/"+@Subset(@DbName;-1)+"/SetFieldAgent?OpenAgent&key="+@Text(@DocumentUniqueID)+">Set Field</a>]"

If you click than on this link, and your SetFieldAgent is some simpler then Sloeber's proposal, like this:
Sub Initialize
  Dim session As New NotesSession
  Dim doc As NotesDocument
  Set doc = session.DocumentContext
  Print "<br>DocId: " & Strright(Ucase(doc.Query_string(0)), "&KEY=")
  Forall item In doc.Items
    Print "<br>" & item.Name & ":<b> " & item.Text & "</b>"
  End Forall
End Sub

Then you get something like this:
DocId: B6A2B971D1CB800EC1256AAC007C1D2D
SERVER_SOFTWARE: Lotus-Domino/5.0.3
SERVER_NAME: localhost
SERVER_PORT: 80
SERVER_PROTOCOL: HTTP/1.0
REQUEST_METHOD: GET
PATH_INFO: /api\oletest.nsf/SetFieldAgent?OpenAgent&key=B6A2B971D1CB800EC1256AAC007C1D2D
PATH_TRANSLATED:
QUERY_STRING: OpenAgent&key=B6A2B971D1CB800EC1256AAC007C1D2D
REMOTE_ADDR: 127.0.0.1
AUTH_TYPE:
REMOTE_USER:
REMOTE_IDENT:
HTTPS_KEYSIZE:
HTTPS: OFF
HTTP_ACCEPT_CHARSET: iso-8859-1,*,utf-8
HTTP_ACCEPT_LANGUAGE: en
HTTP_ACCEPT_ENCODING: gzip
HTTP_ACCEPT: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, image/png, */*
HTTP_HOST: localhost
HTTP_USER_AGENT: Mozilla/4.7 [en] (WinNT; I)
HTTP_CONNECTION: Keep-Alive
HTTP_REFERER: http://localhost/api/oletest.nsf/Show?OpenForm
PATH_INFO_DECODED:
/api\oletest.nsf/SetFieldAgent?OpenAgent&key=B6A2B971D1CB800EC1256AAC007C1D2D
QUERY_STRING_DECODED: OpenAgent&key=B6A2B971D1CB800EC1256AAC007C1D2D

Esspecialy look at decoded version of query_string: QUERY_STRING_DECODED

Regards,
zvonko
0
 
LVL 5

Author Comment

by:snocross
ID: 6454177
Thanks to everyone!
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

For Desktop Techs: How to retain a user's Notes configuration data when swapping out the end user's computer. (Assuming that you are not upgrading to a completely different version of Notes client) All you need to do is: 1) install Notes o…
  In today’s Arena we can’t imagine our lives without Internet as we are highly used to of it. If we consider our life style just for only 2 min we found that face to face communication is swapped by e-communication.  Every Where from Works place to…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now