in

SharePoint Blogs

The Best Place for SharePoint-related Blogs

This Blog

Syndication

All About SharePoint - S.S. Ahmed - MVP Microsoft SharePoint

All About SharePoint, as the name suggests, is all about SharePoint. It has articles, tutorials, source code, FAQs, and tips about SharePoint, InfoPath, C#, Microsoft Office, SQL Server, XML, etc.

Manipulating SharePoint list's metadata from inside InfoPath

Yes, this is possible. You can manipulate SharePoint's list metadata from inside InfoPath. You must have InfoPath toolkit installed. See following post for reference:

http://www.sharepointblogs.com/ssa/archive/2006/06/02/8029.aspx

You can get/set values in SharePoint list. Recently, I was working on a workflow solution that involved both SharePoint and InfoPath. Till now, all the workflow solutions that I developed used SharePoint as the main tool and workflow was built into SharePoint but this time, the requirement was a bit different. We wanted to build the workflow solution directly in InfoPath form and part of this requirement was to set a property's value in document library directly from InfoPath form. "Approval Status" field in form library can contain one of the following values:

1. Approved
2. Rejected
3. Pending

Depending on your form's requirements, you can set the value of "Approval Status" field directly from InfoPath. Here is the code:

SPWeb mySite = new SPSite("http://yourportal/sites/HR/HRForms/Forms/mod-view.aspx").OpenWeb();
SPFolder myFolder = mySite.GetFolder("HRForms");
SPFileCollection myFiles = myFolder.Files;
try
{
foreach (SPFile fyle in myFiles)
{
fyle.Item.ModerationInformation.Status = Microsoft.SharePoint.SPModerationStatusType.Pending;
fyle.Item.Update();
}
}


Code Explanation:

Open your site using OpenWeb() method. In the code above, first line opens a site called "HR". "HR" site has a folder named "HRForms" and this folder contains all forms. In the for-each loop, we are setting each file's status to "Pending". It is important to call the Update() method in order to apply the changes.

Add a reference to Microsoft.SharePoint (Microsoft.SharePoint.dll) and add following namespaces in the code:

using Microsoft.SharePoint;
using System.Collections;

-SSA

Published Jun 16 2006, 03:54 AM by ssa

Comments

 

Thomas said:

Is it possible to update from one Infopath form multiple Sharepoint lists?

August 14, 2008 9:00 AM
 

ssa said:

Thomas,

Yes, create different data connections and execute them in the submit handler.

SSA

August 31, 2008 10:46 PM

Leave a Comment

(required )  
(optional )
(required )  
Add

About ssa

MOSS MVP - Over 8 years experience. 4 years SharePoint experience!

Need SharePoint Training? Attend a SharePoint Bootcamp!

Posts (c) their respective authors. Everything else (c) 2007 SharePoint Experts