Hi All,
I'm having trouble trying automate a web page that receives jscript
variables. Firstly I'm after some advice on the best way to go about what I'm
trying to do (posted below) as my jscript experience is limited . I 've tried
a couple of approaches, which if they are correct I'll need some help
understanding where I've gone wrong and I'll post up the code as necessary.
The scenario:-
I've added a custom button to MSCRM4 which launches a web page that I've
created, however I do not control how that window is opened (i.e.
window.open, size etc). It passes in some variables via
window.dialogArguments (the GUID of an entity selected on a grid for those
that know CRM). Now I need to capture those variables and send them up to the
server, so that I can query the CRM database and return some info. The server
side code then launches a word document with info from the query on the
document.
I've tried two approaches and both have their problems. The first approach
was to set the value of a hidden field to the captured variable and submit
the form in jscript , this then allowed the server to grab the variable and
proccess the code to launch word. It all worked fine except that the submit
appeared to be opening a new browser instance which I could not close despite
trying window.close(), self.close(), top.close(), etc (incidentally it would
close the initial browser instance which was launced from the custom button).
Obviously it's not ideal for the user to be staring at blank web page after
closing word.
The second approach was to create two web pages where the initial page would
open the second via window.open() whilst passing in a querystring of the
captured variable so that the second page could grab the querystring, process
and close itself via self.close() or via setTimeout from the first page.
However while the second page opened successfully it refused to run the
server code.
Are either of these approaches valid and I am going about this problem the
right way? If not does anyone have any advice about the best way to do this?
If they are correct please let me know and I'll post up some code which will
hopefully show where I'm going wrong.
Thanks in advance for any advice anyone can give.
Kevin lott - 17 Jul 2008 13:53 GMT
Solved.
Dear oh dear, this post proves what not taking a break after spending hours
at looking at the same problem does to your brain.
For any jscript newbies like myself who've found this post through a google
search on jscript variables, the second approach of using two windows and a
querystring work fine. Provided you use the correct website address in
window.open()!!