Link to home
Start Free TrialLog in
Avatar of Susan_Murray
Susan_Murray

asked on

Why does agent work fine when called from webquerysave but not from a url link or html

I have a web form that the user attaches a spreadsheet to be processed.  When they hit submit the server picks up the file from the document.context and steps through the worksheets and cells finding the data needed, and creating a Notes Web Form that is then presented back to the user to verify.  This code works perfectly in our test environment..the problem comes in that I have to point the agent to a specific server because it is the only server that has Excel loaded on it.  When I changed my call from a webquerysave, that calls the agent to an html link that launches the agent, it no longer works.  It appears that it can no longer access the information via document.context.  At my wits end..pls. help
ASKER CERTIFIED SOLUTION
Avatar of cezarF
cezarF
Flag of Australia image

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
Avatar of Susan_Murray
Susan_Murray

ASKER

Can I point the webquerysave at the server I want?  If, I save the document and try to retreive it from the backend, there is no telling which server I was on when creating from the web..so it will take at least 20 min to replicate...which is far from the immediate response that I need.  I have never used a cgi variable before...can you help explain it a bit and give me what the code might look like... thanks so much with this...
>Can I point the webquerysave at the server I want?
I'm afraid you cannot.

>I have never used a cgi variable before...can you help explain it a bit and give me what the code might look like.
CGI vars might not help as you are more concern about the attached excel file in the form you are trying to submit.

You might want consider the following alternatives:
1. Install MS Excel in the server where your app is running.
2. If you have issues with MS Excel license, install Open Office and use the Calc (counterpart of MS Excel) OLE to read the attached file.  
if you are keen to explore open office APIs download the SDK from : http://www.openoffice.org/dev_docs/source/sdk/
I mignt have a work around, but I have not tested it and it will take a bit of coding to implement.

(1) Write a web service (or agent) on the server that has Excel installed that takes the UNID of a document in your upload application and performs the necessary work.
(2) Re-wrirte your WebQuerySave agent to call the service (or agent) on the Excel server, passing the UNID of the document that was just saved.

Just an idea.
I cant install excel on all the servers..security dept would never approve of that..had all i could do to have them sign off on one server.
If I save the document and try to load from the unid, the document with the attachment could have been created on any server in the network, and not replicated yet to the server with excel loaded on it.

I will look into the api from sdk...any sample code for this...?
I wrote a random access CSV parser in LotusScript and make my users save their Excel files as CSV.  That way, I don't need to have Excel installed on my servers.
Regarding my first post:  I didn't think it would work.  I've used similar workarounds for web-only apps, but it is still just a work around.  I should have mentioned the CSV parser earlier.
These excel spreadsheets have multiple pages that I have to access, can that be saved as a csv. and if so I can I easily convert an .xls to .csv without the user?
No, that's the main limitation of CSV.  I think you will need to move your app to the server that has Excel installed to get this to work.
SOLUTION
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
Ok. If I have the user link to the ip address and run the agent from there..when excel is done running can I then push the document back to appear under the proper url rather than the ip?
1) Should not need to use IP, each server has a unique host name, even if you also use a round-robin DNS resolution of the "official" host.  Using IP, you will almost certainly run into credentials issues.  Using host anmes, if you play it carefully, you can have the authentication work across multiples

2) If you are asking if you can re-driect the user after the agent click, then yes you can, in one of several ways:
a) have the agent grab the HTTP Referer value to figure out what the previous host name was
b) have the link open in a separate window, or better yet, a hidden frame or layer, so there is never a separate host/IP visible to the user

3) Don't forget, after you redirect, you may not be on the same server anymore, which means the possibility of an out of date copy of the database.
I went to the server document and got the official host name of the server, but when I plug that into the url, I get 404 error..  The only two ways that I have successfully gotten to the application is through the ip (which will cause the authenication issues) and the "official url" .  what am i missing...?
SOLUTION
Avatar of Sjef Bosman
Sjef Bosman
Flag of France image

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
Your DNS definitely needs to have that host name. Notes wants it to. Either that, or the server doc needs to be reconfigured with the correct host name.

There is definitely a DNS entry that resolves specifically to this server, otherwise you woudl probably have trouble accesisng it through your Notes client, unless you use connection documents on your client or a HOSTS file entry.
you might want to try this.

1. in your QuerySave agent, extract the attached file to a file server wherein both your servers can access
2. trigger an agent (using ?OpenAgent) in the server that has MS Excel to read the excel file extracted in step 1 and create a text file  in the file server containing the data to be confirmed by the web user.
3. your QuerySave agent should wait until the text file is created in the file server, read it and display the data to the web user.

step 3 may result into an infinite loop if the agent in the server with MS Excel failed to create the text file. you might want to explore returning string buffer or xml to the calling agent instead of a text file.

 

 
cezarF,

All that is unnecessary if the post goes straight to that server anyway.  A real simple trick for this is to set the BASE HREF to what the URL would be if it had been loaded from that server as well.  BASE HREF affects all relative URLs on the page, including the URL of teh form action.

So, if the ucrrnet URL is http://server-1/db.nsf/formname?OpenForm and the action is /db.nsf/formname?SaveDocument which resolves to http://server-1/db.nsf/formname?CreateDocument 

But, if you add a BASE HREF of http://server-2/db.nsf/formname
Then the post will magically change to http://server-2/db.nsf/formname?SaveDocument 

Which is perfect.
Let me start with I have no control over the DNS or changing it.  I am consulting for a company and the Admin is already not happy with me poking around in his environment.  
The environment is set up using (if these are wrong terms...sorry)  hub and spoke.  So there are 3 servers that serve the web pages and the hub that they all replicate with.  Excel is installed on the hub.  I have tried to ping the server but after trying all the responses I still cant access the hub, unless I go directly to the ip address.
I am now working on something that is very close to what cez is recommending.  I have FTPd the file to the server, and can see it in the backend.  I then call the agent and point the document to be pulled from the server hard drive...but right now it is not opening the file...so not sure what is going on yet with that...if it really hasn;t gotten the file or if it cant load excel.
I like what qwalatee suggests but without a url that resolves to that server(hub) I am not sure if that will work for me..unless I use the ip address....  life shouldn't be this hard.
>>but right now it is not opening the file...so not sure what is going on yet with that

any error message? the agent signer might not have "unrestricted access" to read the file.
Forced accept.

Computer101
EE Admin