Posts Tagged ‘programming infopath’
While you can create a SharePoint List Form to manage multiple SharePoint list items, it becomes a bit more challenging if you want to do the same using a normal SharePoint Form Library Form.
For the latter, you can write code and make use of the Lists web service to maintain multiple items in a SharePoint list. Such code does not require Full Trust to run, so InfoPath form templates can be normally published to SharePoint Form Libraries as sandboxed solutions.
Recipe 95 of InfoPath 2010 Cookbook 3 and InfoPath 2010 Cookbook 4 gives you the basics of adding items from a repeating table to a SharePoint list, and the Discussion section expands on how to add update and delete functionality to such a solution.
However, you can go a step further and expand the solution in such a way that users can easily add rows to the repeating table, update data in rows of the repeating table, or delete rows from the repeating table, and then when the form is submitted back to SharePoint, all of those inserts, updates, and deletes are written in bulk – so with only one call to the web service – back to the SharePoint list.
The InfoPath 2013 demo video below shows you how such a solution would work.
While you can set up communication between an InfoPath 2010 form with an Excel spreadsheet that are both hosted in SharePoint 2010 without writing code to transfer data from InfoPath 2010 to Excel 2010, you can also add more flexibility to your InfoPath browser form solutions by writing code in InfoPath 2010 that can transfer data to create an entirely new Excel workbook in SharePoint 2010.
The first solution generally makes use of Excel Services in SharePoint 2010 in combination with the new InfoPath Form Web Part, while for the second solution you can use the Open XML SDK to create a new Excel spreadsheet from scratch based on the data that is stored in an InfoPath browser-enabled form.
For the latter, no programming would be required in SharePoint itself (although you could write either a SharePoint workflow or SharePoint event receiver that creates the Excel workbook from InfoPath data), but all of the code functionality would be contained in the InfoPath form template. In addition, such a form template would not require Full Trust to run, so can be published directly to a SharePoint Form Library using the usual publishing method from within InfoPath Designer 2010.
The following InfoPath video demonstrates an InfoPath browser form solution where repeating table data is used to create a new Excel spreadsheet right on the SharePoint Server and store the Excel file afterwards in a SharePoint document library.
While this solution uses code, there is also a codeless solution to achieve such functionality, that is, permanently store InfoPath repeating table data in an Excel workbook (new or existing) stored in SharePoint.
As you may already know, Silverlight integrates nicely with SharePoint 2010. Not only that, but once you get past learning the basics of writing code inside and outside of InfoPath forms as taught in the first 6 chapters of InfoPath 2010 Cookbook 3, you can move onto putting together more interesting and cool solutions such as for example using Silverlight to chart InfoPath data for display in SharePoint 2010.
You can use the Silverlight client object model to access data stored in SharePoint 2010. This same technique also allows you to retrieve data that is stored in SharePoint form libraries, so you can access InfoPath forms and the data they contain from within a Silverlight application.
The Silverlight Toolkit comes with a chart control you can use to display InfoPath data in a chart. So once you have retrieved InfoPath forms and their data from SharePoint, you can then use regular .NET programming techniques in a Silverlight application to display InfoPath data in a chart.
The following video is a demonstration of how you can use Silverlight to retrieve data that is stored in a repeating table in one or several InfoPath forms and then display that data on two different ways in a chart on a SharePoint page.
Passing data between InfoPath forms generally involves using parameters, whether these parameters are startup parameters (as is the case with InfoPath Filler forms), query string parameters, or web part connection parameters.
In a previous video, you already saw how you can open an InfoPath form from within another InfoPath form and then pass values from one InfoPath form to the other. But what if you already have both InfoPath forms open in SharePoint and you want to pass data between them?
In the InfoPath video shown below, you’ll see how you can use web part connection parameters to pass data from a repeating table on one InfoPath form to another repeating table on a second InfoPath form while both InfoPath 2010 forms are embedded on a page in SharePoint 2010.
While you can directly connect an MS Access database table to an InfoPath form to retrieve and submit data (as shown in InfoPath 2010 Cookbook), it becomes more difficult when you are dealing with a Microsoft Access database table that contains a Memo field.
In such cases, you must write ADO.NET code in InfoPath to be able to not only add new records to the MS Access database, but also update existing records.
Memo fields can contain long text and are suitable to store the text of for example the base64-encoded string of a picture control or the text of a rich text box control on an InfoPath form.
The following InfoPath 2010 video is a demonstration of three solutions in recipe 88 of InfoPath 2010 Cookbook 3 that will teach you how to write C# code to add, update, and delete records in a Microsoft Access database table that contains a Memo field.
There are two ways you can assign a value to a field in InfoPath 2010:
- Use a Set a field’s value action rule (without code).
- Use the SetValue() method of an XPathNavigator object (with code).
While using rules is the easiest way to assign values to fields, there are occasions on which you would have to use code, for example, when setting the value of fields within a repeating table, because InfoPath does not have an action with which you can set the values of individual fields in a repeating group.
You’ll need either Visual Studio Tools for Applications (VSTA for short) or Visual Studio 2005 or 2008 to be able to program (write code) in InfoPath.
Here’s a list of articles to get you started:
While you don’t have to write code in InfoPath – you could create codeless InfoPath solutions – InfoPath 2007 provides support for VBScript, JScript, Visual Basic .NET, and C# .NET.
If you’re writing code, I suggest you use either Visual Basic .NET or C# .NET, because the scripting languages have been removed from InfoPath 2010.
Visit the InfoPath Developer Center to get started writing code in InfoPath.