Out Of The Box Sharepoint (?)

December 1, 2011

Infopath-fields and custom list-columns

Filed under: Uncategorized — Peter Kruisman @ 11:22 am

I blogged before about Infopath-fields and custom list-columns values from a workflow. It proved to be even more challenging and resulted in a code behind solution. As noted before you can retrieve the ID of the form using a dataconnection:
– Formcode.cs
FormEvents_Loading()
XPathNavigator secunDD = DataSources[“ItemID”].CreateNavigator();
XPathNavigator ID = secunDD.SelectSingleNode(“/dfs:myFields/dfs:dataFields/dfs:DUF/@Id”, NamespaceManager);

I pass this ID to an other class referencing Microsoft.SharePoint. With SPLIST SPITEM and CAML I got hold of the field values
SPLIST:
– SPList splijst = web.Lists[“ListName”];
CAML:
– Squery = string.Format(“<Where><Eq><FieldRef Name=’ID’ /><Value Type=’Counter’>{0}</Value></Eq></Where>”, ID);
SPITEM:
– spcollectieItems = splijst.GetItems(query);
– item = spcollectieItems[0];
– VariableToReturnToFormcodeCS = ( item["FieldName"] == null)? "" : item["FieldName"].ToString();

Advertisements

Create a free website or blog at WordPress.com.