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!