Really struggling - please help - InfoPath Dev
in

InfoPath Dev

Really struggling - please help

Last post 10-01-2007 07:59 AM by Clay Fox. 10 replies.
Page 1 of 1 (11 items)
Sort Posts: Previous Next
  • 09-21-2007 01:54 AM

    Really struggling - please help

    Hi, I have been stuck on this problem for a while now and really hope someone can help.

    I have searched the forums but can seem to find anything specific to my problem.

    I am starting an infopath 2003 form from sharepoint (template is in a document list). What i need to do is prepopulate a textbox on the form with a value. The problem is the value is part of the URL of the sharepoint page im on.

    I have considered many different ways of doing this, get URL using javascript and wrap javascript in a user control on the sharepoint page. Thought about using a webservice etc.... but havnt really arrived at a satisfactory solution.

    Can anyone suggest a way forward on this. I have javascript which gets the URL portion and starts infopath and this functions perfectly within a knocked up HTML page (apart from it still wont pass the value to the field!!!!!!!).

    When i wrap that into the click event of a custom server control in .NET and add it to a web app to test it it cannot create the infopath and falls over.

    Can anyone help please? Is this simply something that just cant be done?

    ps: We HAVE to use infopath 2003 as this is what the users have and its company decision not to deploy 2007 to everyone. I understand this would be very easy in 2007 though :-(

     Hope someone can advise.

  • 09-21-2007 06:43 AM In reply to

    Re: Really struggling - please help

    Have you looked at passing the parameter into InfoPath as it starts?

    I have used windows script and launched InfoPath forms from command line while passing variables.  If you have the URL before hand, then it is just a matter of parsing it for the portion you want and then passing that into a field in your form.  I think this may be easier than trying to pull once InfoPath is running. 

    http://www.infopathdev.com/blogs/jim/archive/2005/09/14/Pass-Parameters-to-InfoPath.aspx

    http://geekswithblogs.net/bpaddock/archive/2004/05/14/4907.aspx This is what I built mine around.

    Good Luck.

  • 09-21-2007 07:03 AM In reply to

    Re: Really struggling - please help

    Clay,

     Thanks for reply. I have seen both these blogs and the second one forms the basis of the javascript i have written.

    my javascript line that does the selectsinglenode part (as per blog above) will not work at all :

    var TargetField1 = oXDocument.DOM.selectSingleNode("field1");

    it returns null and im not sure why. The field name is correct, the only thing i can think of is that currently it is a field bound to the datasource so you cant edit it?? Would that be correct ?

     Also i really dont get the command-line part of the solution. How would this work from our users point of view. I mean if i went with the usercontrol solution .. can a user control invoke a commandline command from within managed code ?? I guess i'll have to have a play around with this.

     thanks for your help so far.

    graham

     

  • 09-21-2007 08:14 AM In reply to

    Re: Really struggling - please help

    On jim's blog there are a couple of things I'm unsure of:

    1/ Where do you define the params. Is this just another xml file or are they defined in one of the files that make up the .xsn for my infopath form template.

    2/ I open the .xsn in winzip so i can see the composite files. When i try to open the manifest.xsf from here i get the following error:

    "Form template: C:\Documents and Settings\graham.cooke\Local Settings\Temp\manifest.xsf
    The following file is either missing or not part of the form template: template.xml

    To add a file to the form template in design mode, click Resource Manager on the Tools menu, and then add the file you want."

     

     

  • 09-21-2007 08:25 AM In reply to

    Re: Really struggling - please help

    You can view the components from Design mode. Go to File and Save as Source Files.

    Maybe give me a bit more information on the solution you are trying to create, what these different URL's will be and how you will have it work in SharePoint. That would help me see what you are trying to accomplish and need and then can maybe think of some options.

  • 09-21-2007 08:42 AM In reply to

    Re: Really struggling - please help

    Basically we are trying to put the finishing touches to a workflow: 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 a document link. When clicked this will open an Infopath 2003 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....) and populated from the db if there is data there.

    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.

     The URL of the subsite created will ALWAYS be: http://emeadevpulse/Emea/SupportServices/Projects/Proposalsite/Pxxxxxx/default.aspx  where pxxxxxx is the ID we want populated on the form when its opened (uniquely identifies the project proposal that has been created).

     The document works fine EXCEPT the pre-population bit. I suggested that the URL portion we want can be obtained with a bit of BLOCKED SCRIPT

    function myfunction()
    {
     var strHRef= window.location.href;
     var subString = strHRef.substr(strHRef.indexOf("Proposal"));
     var splitstring = subString.split("/");
     var strReturn = splitstring[1];
     return(strReturn);
     }

    i have tested this in a HTML page created in notepad and saved in a folder structure that has "propsal" as part of one of the folder names. This works.

    I have also tested this BLOCKED SCRIPT

    function openInfoPathPopulated()
    {
     
     var ProjID = myfunction();
     
     alert(ProjID);

     //<!--Start the application -->
     var oApp = new ActiveXObject("InfoPath.Application");
     
     //var oXDocument = oApp.XDocuments.NewFromSolution("mypath"); 
     
     var oXDocument = oApp.XDocuments.NewFromSolution("C:\\Infopathtemplate\\Template1.xsn"); 
     
     var TargetField1 = oXDocument.DOM.selectSingleNode("field1");

     TargetField1.text = ProjID;

    }

    and this works in so far as it opens infopath - but it doesnt pre-populate the field.

    So my problem is getting the value INTO the field on the doc (which your links should help with) and also putting the code i've written to do this into the sharepoint site to allow the user to do this repeatedly every time a new project proposal is created.

    This is why i thought about a user control in the subsite to launch infopath rather than the document list link.

     I am COMPLETELY new to sharepoint / infopath and all things web. I come from a c# / VB.net windows application development background.

    The javascript above is the first javascript i have ever written !! :-)

     thanks for your help!

  • 09-21-2007 09:06 AM In reply to

    Re: Really struggling - please help

    OK that helps.

    My first thought.  If you are using a database, why not get the Proposal ID from there?  Why try to pass it with the URL when it could be done with the DB?  I would think there would be some way of linking this? If this is an automatic process haveing your form store the last created proposal ID would probably be effective.

    Second I think there is a way to get the URL but maybe that is only for the xsn, which I assume is static in your solution, but here is a thread to check. http://www.infopathdev.com/forums/p/5686/22114.aspx#22114

    Lastly have you looked at the Database Accelerator?  Given the complexity of what you are doing it may be advantageous.  With it you could encapsulate your workflow and probably have greater control than with SharePoint.Qdabra Database Accelerator Suite Version 2.1.2815 - Developer

    I could give you demo of how it may give you more flexibility and fit your needs.

    Filed under:
  • 09-24-2007 12:59 AM In reply to

    Re: Really struggling - please help

    re: database question :) this was the first thing i thought of too !! But at the proposal subsite stage, there is nothing to identify the infopath document we are clicking on in sharepoint EXCEPT the proposal ID.... which we only know at this time becuase it is in the URL !!

     I will look into the Db accelerator. Thanks again.

  • 09-25-2007 07:29 AM In reply to

    Re: Really struggling - please help

    Clay, I have discovered that we could get round all this by simply publishing the form to the new sharepoint subsite. At the moment the form is being copied from a list in the main site. Is there a way to programmitcally change the publish url in the manifest.xsf file ???

     

    This would solve the problem completely i think as we can get the url for the form from where it is published. At the moment becuase we are using a copied form it picks up the publish url of the original !!!

  • 10-01-2007 07:54 AM In reply to

    Re: Really struggling - please help

    Anyone else who is struggling with something similar should look at xsnfixup.js. You need to use the CabSDK from microsoft in conjunction with the javascript.

    MSDN has full details:

    http://msdn2.microsoft.com/en-us/library/Aa192521(office.11).aspx

  • 10-01-2007 07:59 AM In reply to

    Re: Really struggling - please help

    Great!

    Thanks for posting the link.

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