How can one get the .xsn template path from URN based form? (JScript) - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

How can one get the .xsn template path from URN based form? (JScript)

Last post 08-23-2007 06:43 AM by Agni Jonnalagadda. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 08-22-2007 07:35 AM

    How can one get the .xsn template path from URN based form? (JScript)

     

    I’m not sure if this is the correct area to post this question, but here goes.

     

    I am working on an InfoPath form for which I have created an install to place the .xsn on the end user’s local machine. At install the form is made fully trusted (this is accomplished via the RegForm tool available in the SDK). Once the user has run the install the form is apparently URN based rather than URI. This is where my problem begins. The form contains budgeting data that is written to an Excel spreadsheet (via Jscript) which is installed to the same directory as the InfoPath .xsn file.

     

    Now that the form is URN based the XDocument.Solution.URI property no longer returns the directory path I need to provide in the script to reference the location of the Excel file I need to write the data to.

     

    So my question is: Can anyone point me in the right direction to how I might go about acquiring the directory path to a form’s template (in JScript) such as C:\MyDirectory\MyInfoPathForm.xsn when the form is URN based? Or, perhaps how I might be able to go about providing the user the ability to browse for the file to provide the path like in HTML using the <input type="file" /> tag. I could use something like that just to pass the path to the script.

     

    Keep in mind that I have to use a pre-existing .xls document, that contains too many custom features to recreate via scripting, not generate it from scratch (which would of course make life easier of course :P) .

     

    As always ... have a day :|
    Filed under:
  • 08-22-2007 09:07 AM In reply to

    Re: How can one get the .xsn template path from URN based form? (JScript)

    Only way you can get this done is writing some custom code which accesses the registry. I think you should search in Google on how to access the registry from code.

     

  • 08-22-2007 10:00 AM In reply to

    Re: How can one get the .xsn template path from URN based form? (JScript)

     Agni,

     First let me thank you for your reply. This has got me going in the right direction as I have now located where the path is being stored in the registry. Now I've just got to whip up some more code that will search for this key and return its value.

    Thanks again ... Nym
     

    As always ... have a day :|
  • 08-22-2007 01:52 PM In reply to

    Re: How can one get the .xsn template path from URN based form? (JScript)

     Agni, yep I was able to pull this off by creating a WScript.Shell ActiveXObject.  Presently I'm just hard coding the registry path but will later have to revisit this to search for the path as it will of course change depending on the version of MS Office the client is running.


    Thanks once more for your input it was more helpful than you can imagine. Now I will succumb to the melting of my brain caused by the joys of scripting to make InfoPath do that which it was not meant to do  :P
     

    As always ... have a day :|
  • 08-23-2007 01:38 AM In reply to

    Re: How can one get the .xsn template path from URN based form? (JScript)

    Great that it has helped you. Why don't you post your code to access the registry here? It will be helpful to others as well.

  • 08-23-2007 05:55 AM In reply to

    Re: How can one get the .xsn template path from URN based form? (JScript)

    Here is a simple function I put together with a hard coded registry path. A few things to keep in mind about using this function. First the form it is used by has been installed on the users local machine and made fully trusted at install (via script generated by the RegForm tool found in the InfoPath 2003 SDK). Basically this registers the from on the user's system which converts the form from URI based to URN based so, at least in InfoPath 2003, the XDocument.Solution.URI property no longer returns the file path to the from template rather it returns the URN. The path below is specific to InfoPath 2003. I think it will be as simple as changing 11.0 to 12.0 for InfoPath 2007 but I haven't gotten to that point yet. The path if the client machine is running InfoPath 2007 will be the same with the "11.0" level omitted. The URN will of course need to be replaced with the URN from whatever form one may want to retrieve the path for.

    function cad_getIPFTPath(){

                var WshShell = new ActiveXObject("WScript.Shell");

                // Get path for InfoPath 2003

                var thePath = WshShell.RegRead("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Office\\11.0\\InfoPath\\SolutionsCatalog\\urn:xxxxxx:xxxx\\Original Location");

                // XDocument.UI.Alert("thePath is: " + thePath);

                return thePath;

    }

    As always ... have a day :|
  • 08-23-2007 06:43 AM In reply to

    Re: How can one get the .xsn template path from URN based form? (JScript)

    Thanks for the code.

Page 1 of 1 (7 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.