Change location secondary DataSource for InfoPath browser-based May 13, 2008
Posted by spunkyvt in Programming, Sharepoint.Tags: DataSource, InfoPath, SPList, SPQuery
add a comment
The title is a little misleading, because we are not actually changing the datasource.
In the FormEvents_Loading method put this code
String titleName = e.InputParameters["XmlLocation"].Substring(e.InputParameters["XmlLocation"].LastIndexOf(“/”)+1);
using (SPSite site = new SPSite(_baseURL))
{
using (SPWeb web = site.OpenWeb())
{
SPList ls = web.Lists[_FormName];
SPQuery query = new SPQuery();
query.Query = “<Where><Eq><FieldRef Name=’Title’/><Value Type=’Text’>” + titleName + “</Value></Eq></Where>”;
SPListItemCollection its = ls.GetItems(query);
string h = its[0]["ColumnName"].ToString() ;
}
}
Dynamic Submit with Infopath browser May 8, 2008
Posted by spunkyvt in Programming, Sharepoint.Tags: InfoPath, Sharepoint
add a comment
Ever need to develop an infopath form, but deploy it to another machine and not go through the hassel of Microsofts tool or bringing each form up in infopath and changing location.
First make a data connection and call it ChangeSubmit
Place a button on the form.
In the clicked event from code behind put this code
FileSubmitConnection submit = (FileSubmitConnection)this.DataConnections["ChangeSubmit"];
submit.FolderUrl = “pathtoyourformlibrary”;
submit.Execute();
You can make this much more dynamic, but I just wanted to show the simple version on how to switch this.
Dynamically Add to Drop-Down in Infopath using a Web Service May 7, 2008
Posted by spunkyvt in Programming, Sharepoint.Tags: drop-down, InfoPath, Sharepoint, web service
add a comment
OK. After banging my head about for hours now, I have finally found a solution. This is going to use the permissions built into Sharepoint. It will list out all the groups that have permissions to a form library.
First you need to make an xml file.
Create an xml file with this info in it. Name it Permiss.xml.

Drag a drop-down box onto the infopath form. Click on DataConnections under tools. Click the add button. Create a new connection and set it to Receive Data. Click the Next and choose XML Document. Browse to the file location and choose the Permiss.xml file. Cick next and Make sure that Automatically retrieve data when form is opened is checked.
Right Click on the Drop-Down List Box properties. Click on the Look up values from an external data source. In the Data source drop down pick permiss. Click on button beside Entries and choose the permissions node. Click OK. Next click button beside Value and choose MemberID. Click OK. Click the button beside Display name and choose GroupName. Finally all done there.
Now onto the code behind.
Add a web reference to the http://localhost/_vti_bin/permissions.asmx
Call it permission.
In the FormEvents_loading method add this code
permissions.Permissions perm = new GFill.permissions.Permissions();
perm.Credentials = System.Net.CredentialCache.DefaultCredentials;
String FormName = “youLibrary”
XmlNode nod = perm.GetPermissionCollection(FormName, “List”);
XPathNavigator sitepermiss = DataSources["permiss"].CreateNavigator() ;
XmlNamespaceManager umanager = new XmlNamespaceManager(sitepermiss.NameTable);
umanager.AddNamespace(“ns1″, “http://schemas.microsoft.com/sharepoint/soap/directory/”);
XPathNavigator f1 = sitepermiss.SelectSingleNode(“//ns1:GetPermissionCollection/ns1:Permissions”, umanager);
XPathNavigator g = nod.CreateNavigator().SelectSingleNode(“//ns1:Permissions”, umanager);
f1.ReplaceSelf(g);
If all goes well this is all you should need in order to dynamically fill those drop-downs. I have to vent for a second. This is way harder than it should be. Something this simple and trivial should not have been this complicated to implement. Kudos Microsoft. You win the Rube Goldberg award for the day. I hope this will save someone else numerous hours.
