Link to home
Start Free TrialLog in
Avatar of deonva
deonva

asked on

WEB-Getting Form Fields via notesagent

Are there any way to get to a web form (html) field elements (values) via a notes agent?
The scenario is this:
A html form (not in notes) action (onSubmit) points to a notes database agent, in this agent I have to be able to access the values sent via the form. I know that if I do this from a notes document to notes agent, I can access the values via session.DocumentContext.

Anyone have a idea?
Avatar of deonva
deonva

ASKER

Sorry, I didn't mention that I use Lotus Script in the agent.
in a notesagent that is not possible. but you can always write a servlet on the domino server that can access both your html page and a notes database
Run the agent in WEbQuerySave event and you should be able to access the field values.

PS: HTML Fields created vie html tags cannot be seen by agents.

~Hemanth
Hello  deonva,

is it true that you like to process web form by a Domino agent without having a corresponding form in Domino with same fields and form name?

If this is true, that I do have a solution for you. ;-)

Regards,
stamp
Avatar of deonva

ASKER

Yes Stamp.
The web form is totally unrelated to domino.
I have to access the field values on the form via a notesagent.
ASKER CERTIFIED SOLUTION
Avatar of stamp
stamp

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
A different approach is to use Javascript inside the HTML page to call the agent with

First, your submit button should not be a 'real' submit button, but do something like:

var fieldToPass1 = "&fieldName1="+document.forms[0].fieldToPass1.value;
var fieldToPass2 = "&fieldName1="+document.forms[0].fieldToPass2.value;
.
.
.

var queryString = "/AgentName?OpenAgent"+fieldToPass1+fieldToPass2+...;

var nsfPath = "path to nsf file (inc domain if different)";

window.location = nsfPath + queryString;



Then in the notes agent, use this to get the query string:

dim s as new notesSession
dim doc as notesDocument
set doc = s.documentContext

dim queryString as String
queryString = doc.Query_String(0)

This will give you a text string (queryString) containing everything to the right of the ? in the URL you used.

This can then be split up. Check this thread for string manipulation techniques:

http://www.notes.net/46dom.nsf/55c38d716d632d9b8525689b005ba1c0/b7e3adb3ca84fb0685256879007279ea!OpenDocument
Hello  deonva,

give me the points, not to tgebruik ;-))

both proposals are halfaway.

First: if you like to have all fields in Query_string, than you do not need not a line JavaScript: browser does this for you.
Simple exchange in my html example:
method="POST"

with this:
method="PUT"

Browser puts then for you (withouth any JavaScript :-)) all html form fields and their values into query string!
Because browser do not know anything about Domino, they place the complete query_string behind a question mark. This is also not a problem: give the browser a first field with a name OpenAgent, like this:
<INPUT type=hidden name=OpenAgent>

After pressing the submit button (without any JavaScript) like in my upper html file, than you get this URL calling your agent:
http://localhost/app/sapnote.nsf/ShowAllFields?OpenAgent=++&fieldA=valueB&fieldB=valueB

This does not disturb the agent, it works.
But do not use, like tgebruik said, this item:
queryString = doc.Query_String(0)

Better use this item:
queryString = doc.QUERY_STRING_DECODED(0)

And here you see also why Query_String is not a good way to pass fields: if you do it with JavaScript, than you have to encapsulate it with escape() function to avoid special chars in the URL. This done by method="PUT" by default. But still is method="POST" the better choice.

Also the URL from  tgebruik to this thread is not an experth worth. This experts write in header, they use Release5, buth it seams they never heard about new string functions in LotusScript!
Parse your strings with: strLeft and strRight
And if you prefer usung evaluate, than do it with @Word, and not with @Right or  such command avalable as function in LostusScript R5.

If you need an example for exploding REQUEST_CONTENT or extracting single keyword-value pairs from it, then let me know.
For example, my getParmValue looks like this:
Function getParmValue(Byval ParamString As String, Byval Keyword As String) As String
 Dim Value As String
 getParmValue = ""
 Value = Strright(ParamString, Keyword & "=")
 If (Value > "") Then
     If Instr(1,Value, "&") Then Value = Strleft(Value, "&")
 End If
 getParmValue = Value
End Function

But I think, this is best done by yourself. My function, for example, is CaseSensitive ;-))

So long,
stamp
Stamp is really stamping.....

This time over tgebruik.......... :-(
Hey tgebruik,

take it sportive :-)

Sorry, but I was realy proud to have heared about this method="POST". I got this info from a web summit TheView hold in Amsterdam. I shared this info here, but the only one who was interested was Gus. And then now you came along with this JavaScript...

But here I will give you a new try: I abadone my account stamp.
I just asked EE community support to switch my account stamp to my first account Zvonko I registered and newer used. They told me, only question points are transferable; history and expert points would disappear :-(

So look for Zvonko comming up from zero to hundret! <|;-)

Regards,
stamp
Avatar of deonva

ASKER

This is perfect, thanks Stamp!
I didn't want to use query string decoded (am using it in other apps).  I needed to get hold of html form fields.
to deonva: Thank you for the points and for the feedback ;-)
(working on this http notifier :-))
So long,
stamp

to tgebruik: Have you passed the performance&tunig test (EX#525), Danny?
 
Nope....didn't do that one.... :-) I passed transitioning,
why you asked???
You went to Amsterdammned .., where do you come from???,
to Danny: I am work now in Munich. I am Principal like you :-) ,but only Designer. In Administration only regular CLP ;-)

I am asking for examen 525 to get some hints how to pass this admin brunch before Rnext testing comes :-)
So, you are working in Munich...
Isn't all Software there in German???

I'm now Dual Principal and according to Lotus there are 428 others in line.. :-)
And yes,....starting again in (I presume) 2002.. :-(
RNext.....

I did Transitioning because I thought it would be better because of all companys going from R4 to R5..just to be prepared..

Are you German???

I'm Dutch

and there are'nt that many Europeans in this group...(that i know of)
no, I am not German.

I was born in Makedonia (Aleksandar, the Great! ) ;-))

Transitioning is a good idea, but I usualy abadone whole domain :-), and start from scratch a new one.
So I do not know all the problems other people have when migrate...
Even new server releases are for me no upgrades. I create allways a new notesdata with old server.id from an existing server untill all server have the new release. We can do this because we have only developers mail files and only few tousends  web users.
And I do this on OS/390 ;-)

It is realy funny stuff...
Avatar of deonva

ASKER

Stamp
Re your accepted comment. It works, exept I don't get the item REQUEST_CONTENT. Anything special I should do?
Avatar of deonva

ASKER

Stamp
You can try http://www.net-online.co.za/test.htm to see the results...