open infopath 2003 form from sharepoint 2007 document list and pre-populate a field - InfoPath Dev
in

InfoPath Dev

open infopath 2003 form from sharepoint 2007 document list and pre-populate a field

Last post 09-19-2007 03:57 AM by grahamC. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 09-18-2007 01:51 AM

    open infopath 2003 form from sharepoint 2007 document list and pre-populate a field

    hi,

    I have looked around the forum and found bits of posts that may be helpful to what i want to do but i just want to confirm that i am correct that this can be done ??

    I have a sharepoint site that produces a workflow for creating project proposals. The project proposal form is based on a published template in inofpath 2003.

    Basically when a user clicks generate proposal webpart button in sharepoint database entries are created in sqlserver db and an ID is assigned and a subsite for that proposal site is created. In that newly created subsite we put the infopath form based on the published infopath template in the mainsite (we do not want to publish EVERY document that is created for all the subsites though....). What we really want is when the infopath doc is opened from the new project proposals subsite.. is to have the project ID displayed in the first field. The project ID can be taken from a part of the URL of the subsite by a bit of string manipulation.

     I have two questions really:

    1/ can this actually be done in infopath 2003 ?

    2/ if so, is the following how to all i need ?? http://www.infopathdev.com/blogs/jim/archive/2005/09/14/Pass-Parameters-to-InfoPath.aspx

    I think the how to will only work for a published document as you need to change the manifest etc...... We would ideally like all this fully automated for the user (as its a workflow) and not have to do any specific actions for each new document created in the subsites.

     I hope i have been clear in my explanation !

     Appreciate any help/advice/pointers to samples that do this.

    Filed under: ,
  • 09-18-2007 04:05 AM In reply to

    Re: open infopath 2003 form from sharepoint 2007 document list and pre-populate a field

    ok i've been trying to test this... i have created a little html page with some javascript as follows:

    <html xmlns="http://www.w3.org/1999/xhtml">

    <head>

    <title>Test bit of javascript page</title>

    <script type="text/javascript">

    function myfunction()

    {

    var strHRef= window.location.href;

    var subString = strHRef.substr(strHRef.indexOf("Proposal"));

    var splitstring = subString.split("/");

    var strReturn = splitstring[1];

    return(strReturn);

     

     

    }

    </script>

    </head>

    <body>

    <script type="text/javascript">

    function openInfoPathPopulated()

    {

    var ProjID = myfunction();

     

    alert(ProjID);

    //<!--Start the application -->

    var oApp = new ActiveXObject("InfoPath.Application");

     

    var oXDocument = oApp.XDocuments.NewFromSolution("c:\infopathtemplate\fifth.xsn");

    var targetField1 = oXDocument.DOM.selectSingleNode("//my:ID0");

    targetField1 = ProjID;

    }

    </script>

    <form>

    <input type="button" onclick="openInfoPathPopulated()" value="Call function"/>

    </form>

    <p>By pressing the button, a function will be called. The function will alert a message.</p>

    </body>

    </html>

    but i'm getting a problem with the path of the file to be opened: "the path referred to by an object model must be absolute".

     i'm pretty new to all this.............. any ideas ??? Hopefully im on the right track with this.

  • 09-19-2007 03:57 AM In reply to

    Re: open infopath 2003 form from sharepoint 2007 document list and pre-populate a field

    I've got round this problem now. I think you need to reference a published template with a full http path. Also you need to put an extra "\" char in for every "\" that appears in the path. (due to c# escape characters).

     So my javascript all works. Now i just need to wrap that up in a button that can be placed on a sharepoint page as a user control and possibly then have that control wrapped up in a web part.

     That may be a little beyond the scope of this forum as i appreciate this is moving away from infopath functionality somewhat.... but if anyone has any ideas i'd be happy to hear them :-)

     cheers,

    graham

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