S.documentcontex on the web

Hi,

I’m trying to run a web agent without success (the agent was working fine before…).

My document is open on the web and from an action button I can my agent:

@Command([ToolsRunMacro]; “(Web GoToWIP)”)

My script does not recognized my current document.

I minimized my script to this :

Dim session As NotesSession

Set session = New NotesSession

Dim doc As NotesDocument

Set doc = session.DocumentContext

Print "<H2> Form : " + doc.Form(0) + "</H2>"

My field value is always empty, but the doc is NOT nothing (not even a value for the form field.) I tried the doc.UniversalID, it returned a value, I did a search with this value in the database, any document with this id…

Is it a bug with the domino release? Any ideas??

Thanks!

Genevieve

Subject: s.documentcontex on the web

Have you taken a look at the Request_Content of the DocumentContext? I have a sneaking suspicion that you’ll find that the agent thinks it’s been invoked with a GET rather than a POST (by a server-side redirect). If it IS a POST, then the Request_Content will have your field values in it.

Subject: RE: s.documentcontex on the web

I tried :Msgbox "KEY = " & doc.Request_Content(0)

still blank… what does this mean?

Thank you Stan for your help!

Subject: RE: s.documentcontex on the web

It means my guess was probably correct, that the agent thinks it was served to reply to a GET request. That means that you’ve got nothing but the request header and the URL to work with – the form the button was on, and the fields that were on that form, are not available to you at all. If you need the values that were on the form, then you’ll need to make the agent a WebQuerySave agent, or POST the form directly to the agent. This JavaScript should do the submit:

function switchAndSubmit() {

document.forms[0].action = ‘’;

document.forms[0].submit();

}

Make your button run the switchAndSubmit() function instead of the Formula Language, and you’re all set.

Subject: RE: s.documentcontex on the web

Tried what you told me, now in the field request_content, I get :

__Click=0&%25%25ModDate=85256DD3007194FD&PONumber=00005B&PODate=072103&Customer=Vetement+Tabco&Department=&ExFactory=111003&SecExFact=&Receive=122003&Cancel=&Season=SP04&StyleNumber=S54102&Label=Gusti+X-Treme&FOB=7.30&Currency=U.S.&Unit=un&FOB_1=&PackingInstr=solid+size-solid+color&Notes=&SizeRange=4-6X+%287%29&Ratio=No&RatioB=No&RatioC=No&PrxTkt=Yes&Insem=No&Color1=Ocean+Blue&Sz1=142&Sz2=100&Sz3=142&Sz4=184&Color2=Rose&Sz1_1=102&Sz2_1=72&Sz3_1=102&Sz4_1=132

but I still cannot access simply the value of my document like

temp1 = doc.PONumber(0)

Normal? Otherwise how I can I retrieve values from this big field?

Thanks again Stan!

Subject: RE: s.documentcontex on the web

The Request_Content is filled with fieldname-value pairs. You’ll find them as:

Fieldname=value&fieldname2=value2&fieldname3=value3

You will have to parse the values out of the Request_Content. Since you’re on ND6, you can use the Split method to separate the values out into an array like:

Dim NameValuePairs As Variant

NameValuePairs = Split(doc.Request_Content(0),“&”)

Then, for each of the array members, you’ll find the fieldname with StrLeft (using “=”) and the value using StrRight (again, using “=”). If you want, you can create fields on your DocumentContext:

Forall nv in NameValuePairs

doc.ReplaceItemValue(StrLeft(nv,“=”),StrRight(nv,“=”))

End Forall

That, unfortunately, creates the fields with text values. You can add handling to the agent to convert the strings to the correct data type to fill the fields, and you can also separate multiple values if you need to (as long as you know ahead of time what the separator should be). You’ll also want to make sure that a field is not created for _Click if you need to save the document.

Subject: RE: s.documentcontex on the web

I finally found a way to get my po number :

sMacro = |@Middle(Request_Content; “PONumber=”; “&PODate”)|

vEval = Evaluate (sMacro, doc)

sPONumber = vEval(0)

Msgbox "PO Number = " & sPONumber

The only thing I really don’t like is the fact that my document has to be in edit mode otherwise I cannot submit the document…

Subject: s.documentcontex on the web

Are you sure the Form value is set to something? Unless you have an explicit Form field, this may not get set until after the document is saved.

Subject: RE: s.documentcontex on the web

I tried many fields on the form. Value always = “”