Responsive Ads Here

Friday, November 9, 2012

Retrieving Infopath XML Content From Form Library Using Server Object Model



If your form submits to SharePoint, you can control which fields in your form show up as columns in the SharePoint library view. You need to “promote” any fields you want to show as columns.  (This also controls which fields show up when you export the library info into Excel, for example.)

To specify which fields are promoted in a form that already submits to SharePoint, change the Form Options under the File tab.



 

Select Property Promotion on the left, and use the Add and Remove buttons to control which fields will be promoted. (If you want the column names to be different than the field names, click Modify to customize them.) Click OK when done.

Finally, publish the form again to make the changes on SharePoint.

After doing the property promotion you can able to see the columns in sharepoint form library. So you can easily query the form column using caml desginer.
Below are the steps to do that

        SPList spList = SPContext.Current.Web.Lists.TryGetList("On Boarding Process");  
         if (spList != null)  
         {  
           SPQuery qry = new SPQuery();  
           qry.Query = @"<Where><Eq><FieldRef Name='LinkFilenameNoMenu' /> <Value Type='Computed'>" +       item + "</Value></Eq></Where>";  
           SPListItemCollection itemColl = spList.GetItems(qry);  
     foreach (SPListItem oitem in itemColl)  
     {  
       var firstname = oitem["First Name"];  
       if (firstname != null)  
       {  
         if (!string.IsNullOrEmpty(firstname.ToString()))  
          {  
             olrDetails.firstName = firstname.ToString();  
          }  
        }  
     }  




 

                        






No comments:

Post a Comment