Search This Blog

Thursday, December 4, 2014

InfoPath - SharePoint 2010

>What is an InfoPath?

InfoPath is an XML based electronic forms development product. 

Why InfoPath?

In this tip article we can see the advantages of InfoPath Forms compared with SharePoint List Forms.
You know that we for a SharePoint List, for new / edit / delete operations we can invoke:
· SharePoint Built-in Forms
· InfoPath Forms
Following are the screen shot of both the forms:
image
Following are the advantages of using InfoPath Forms compared with the default forms.
Custom Design PossibilityWe can design the forms using InfoPath Designer which allows much more layout & user control choice.
Better Formatting OptionsMore colors & data formatting options are possible.
Better Validation OptionsBetter validations are possible
Better Data Entry through Repeating & Nested SectionsRepeating Sections allow capturing of repeating set of data. For example multiple contacts addresses with same kind of fields like address, city, and state.
Lookup Data from various sourcesWe can lookup through different data sources like external content, web services etc.
Offline Form FillingForms can be send to users for offline filling (through email attachment)
Digital SignatureUsers can digitally sign the form
Managed Code IntegrationWe can write custom code for much more control.
Late Form SubmissionsCompleted forms can be submitted later on through the Submit feature of InfoPath form filler.
The advantages are depicted below:
image

What are the benefits of InfoPath 2007?
Prior to the introduction of Office 2007, the InfoPath client application, like other Office products, had to be installed on every user’s computer.
In order to develop and use a form:
1.The form had to be designed using InfoPath.
2.The resulting form template should be hosted in a network file share, or installed in individual user machines, or uploaded into a form library in SharePoint, from where users could fill the forms.
3.Filling up forms required InfoPath to be installed on the client machine.
4.Developing a connected InfoPath was complicated for end users.
5.Developers didn’t have an integrated development platform.
6.The product didn’t integrate with other Office products such as Word and Excel.
Benefits of Office 2007
This introduced a new server-side runtime to host InfoPath forms known as InfoPath Form Services. The new capabilities include:
1.Ability to convert Word and Excel documents into InfoPath form templates.
2.With the help of InfoPath form services, a InfoPath form can be browser enabled.
3.The new InfoPath forms can be embedded in Outlook.
4.The form can be built once and rendered in different modes and devices, .i.e., Design Once.
5.Introduction of the document information panel. I.e., an InfoPath form that is hosted inside Word 2007 or PowerPoint 2007 can be used to edit document properties.
6.Introduction of logic inspector. The components which provide visual view of all the rules embedded in the form.
7.The new InfoPath forms can be published to content types.
8.Introduction of template parts, i.e., reusable code sections.
9.Introduction of an integrated development environment inside Visual Studio 2005 using Visual Studio Tools for Office.
10.The information right management can be used to protect sensitive data in the form.
>What is the structure of an InfoPath form template?
The InfoPath form template (.xsn file) is actually a CAB file [can also be considered a zip file] containing the different component files of which InfoPath is built. Following are some of the important files contained inside that CAB file:
1..xsf
2..xsl
3..xsd
4..dll
5..htm and other resource files.
>What is a .xsf file? Or what is the Form Definition file [XSF file]? Or what is a manifest.xsf file?
It’s a manifest file that provides the basic definition of other form files. This file contains XML code that describes all aspects of a form. The .xsf file is automatically created by InfoPath when a new form template is created and saved in Design mode. As form designers and developers change the form template or add new features to it, InfoPath updates the .xsf file to reflect those changes.
Note: The .xsf file can also be modified directly by using any text or XML editor, such as Microsoft Notepad. However, care should be taken when making modifications to the .xsf file: if an invalid entry is made, the form that the file is associated with may be left in an unusable state. However, some customizations can be made to the .xsf file that cannot be generated in Design mode.
The .xsf file is the core file of an InfoPath form because it contains information about the form as a whole. Some of the data it contains includes processing metadata, user interface customizations, schema definitions, views, business logic declarations, event handlers, and deployment information.
The following are some of the items that the .xsf file contains:
•A unique identifier for the form
•Global metadata information about the form, including deployment and publishing information
•The XML schema definitions for the XML document that the form produces
•Definition of views and their associated user interface components (menus, toolbars, and buttons)
•Definition of editing actions that are made available using user interface components, and how their availability will be determined contextually
•Workflow and routing information
•Event handlers, data validation, and business logic that is associated with individual XML nodes of the form’s underlying XML document, or with the XML document itself
•Event handlers associated with the form as a whole
•Packaging information about all of the files contained within the form template
The .xsf file is based on the xsf namespace. Its root element is the xDocumentClass element.
 
<?xml version=”1.0″ encoding=”UTF-8″?>
<!–
This file is automatically created and modified by Microsoft Office InfoPath.
Changes made to the file outside of InfoPath might be lost if the form template
is modified in InfoPath.
–>
<xsf:xDocumentClass trustSetting=”automatic” solutionFormatVersion=”2.0.0.0″ 
   dataFormSolution=”yes” solutionVersion=”1.0.0.6″ productVersion=”12.0.0″
   publishUrl=”" 
   name=”urn:schemas-microsoft-com:office:infopath:Unpacked:-dataFormSolution”
   xmlns:xsf=”http://schemas.microsoft.com/office/infopath/2003/solutionDefinition“ 
       xmlns:xsf2=”http://schemas.microsoft.com/office/
                   infopath/2006/solutionDefinition/extensions” 
       xmlns:msxsl=”urn:schemas-microsoft-com:xslt” 
       xmlns:xd=”http://schemas.microsoft.com/office/infopath/2003“ 
       xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance“ 
       xmlns:xdUtil=”http://schemas.microsoft.com/office/infopath/2003/xslt/Util“ 
       xmlns:xdXDocument=”http://schemas.microsoft.com/office/infopath/2003/xslt/xDocument“ 
       xmlns:xdMath=”http://schemas.microsoft.com/office/infopath/2003/xslt/Math“ 
       xmlns:xdDate=”http://schemas.microsoft.com/office/infopath/2003/xslt/Date“ 
       xmlns:xdExtension= xmlns:xdEnvironment= 
          “http://schemas.microsoft.com/office/infopath/2006/xslt/environment“ 
       xmlns:xdUser=”http://schemas.microsoft.com/office/infopath/2006/xslt/User“ 
       xmlns:q=”http://schemas.microsoft.com/office/infopath/2003/ado/queryFields“ 
       xmlns:d=”http://schemas.microsoft.com/office/infopath/2003/ado/dataFields“ 
       xmlns:dfs=”http://schemas.microsoft.com/office/infopath/2003/dataFormSolution“ 
       xmlns:my=”http://schemas.microsoft.com/office/infopath/2003/myXSD/2007-03-19T15:02:59“ 
       xmlns:xdado=”http://schemas.microsoft.com/office/infopath/2003/adomapping“>
  <xsf:package>
    <xsf:files>
      <xsf:file name=”schema.xsd”>
        <xsf:fileProperties>
          <xsf:property name=”editability” 
             type=”string” value=”none”></xsf:property>
          <xsf:property name=”namespace” type=”string” 
             value=”http://schemas.microsoft.com/office/infopath/
                    2003/dataFormSolution”></xsf:property>
          <xsf:property name=”rootElement” type=”string” 
                value=”myFields”></xsf:property>
          <xsf:property name=”useOnDemandAlgorithm” 
             type=”string” value=”yes”></xsf:property>
        </xsf:fileProperties>
      </xsf:file>
      <xsf:file name=”schema1.xsd”>
        <xsf:fileProperties>
          <xsf:property name=”namespace” type=”string” 
             value=”http://schemas.microsoft.com/office/infopath/2003/ado/dataFields“>
          </xsf:property>
          <xsf:property name=”editability” type=”string” 
                  value=”none”></xsf:property>
        </xsf:fileProperties>
      </xsf:file>
      <xsf:file name=”schema2.xsd”>
        <xsf:fileProperties>
          <xsf:property name=”namespace” type=”string” 
             value=”http://schemas.microsoft.com/office/infopath/2003/ado/queryFields“>
          </xsf:property>
          <xsf:property name=”editability” type=”string” 
             value=”none”></xsf:property>
        </xsf:fileProperties>
      </xsf:file>
      <xsf:file name=”template.xml”></xsf:file>
      <xsf:file name=”sampledata.xml”>
        <xsf:fileProperties>
          <xsf:property name=”fileType” type=”string” 
                      value=”sampleData”></xsf:property>
        </xsf:fileProperties>
      </xsf:file>
      <xsf:file name=”view1.xsl”>
        <xsf:fileProperties>
          <xsf:property name=”lang” type=”string” value=”1033″></xsf:property>
          <xsf:property name=”queryView” type=”string” value=”yes”></xsf:property>
          <xsf:property name=”componentId” type=”string” value=”12″></xsf:property>
          <xsf:property name=”xmlToEditName” type=”string” value=”12″></xsf:property>
          <xsf:property name=”mode” type=”string” value=”1″></xsf:property>
        </xsf:fileProperties>
      </xsf:file>
    </xsf:files>
  </xsf:package>
  <xsf:importParameters enabled=”yes”></xsf:importParameters>
  <xsf:extensions>
    <xsf:extension name=”SolutionDefinitionExtensions”>
      <xsf2:solutionDefinition runtimeCompatibility=”client server” 
                   allowClientOnlyCode=”no”>
        <xsf2:offline openIfQueryFails=”yes” cacheQueries=”yes”></xsf2:offline>
        <xsf2:server isPreSubmitPostBackEnabled=”no” isMobileEnabled=”no” 
                   formLocale=”en-US”></xsf2:server>
      </xsf2:solutionDefinition>
    </xsf:extension>
  </xsf:extensions>
  <xsf:views default=”View 1″>
    <xsf:view name=”View 1″ caption=”View 1″>
      <xsf:mainpane transform=”view1.xsl”></xsf:mainpane>
      <xsf:editing>
        <xsf:xmlToEdit name=”DimCustomer_7″ 
              item=”/dfs:myFields/dfs:dataFields/d:DimCustomer” 
              container=”/dfs:myFields”>
          <xsf:editWith caption=”DimCustomer” 
                  xd:autogeneration=”template” component=”xCollection”>
            <xsf:fragmentToInsert>
              <xsf:chooseFragment parent=”dfs:dataFields” innerFragment=”d:DimCustomer”>
                <d:DimCustomer CustomerKey=”" Title=”" 
                     FirstName=”" MiddleName=”" LastName=”" 
                     BirthDate=”" MaritalStatus=”" 
                     Suffix=”" Gender=”" EmailAddress=”" 
                     AddressLine1=”" AddressLine2=”"></d:DimCustomer>
              </xsf:chooseFragment>
            </xsf:fragmentToInsert>
          </xsf:editWith>
        </xsf:xmlToEdit>
      </xsf:editing>
      <xsf:menuArea name=”msoInsertMenu”>
        <xsf:menu caption=”&amp;Section”>
          <xsf:button action=”xCollection::insert” 
             xmlToEdit=”DimCustomer_7″ caption=”DimCustomer”></xsf:button>
        </xsf:menu>
      </xsf:menuArea>
      <xsf:menuArea name=”msoStructuralEditingContextMenu”>
        <xsf:button action=”xCollection::insertBefore” xmlToEdit=”DimCustomer_7″ 
              caption=”Insert DimCustomer before” showIf=”immediate”></xsf:button>
        <xsf:button action=”xCollection::insertAfter” xmlToEdit=”DimCustomer_7″ 
              caption=”Insert DimCustomer after” showIf=”immediate”></xsf:button>
        <xsf:button action=”xCollection::remove” xmlToEdit=”DimCustomer_7″ 
              caption=”Remove DimCustomer” showIf=”immediate”></xsf:button>
        <xsf:button action=”xCollection::insert” xmlToEdit=”DimCustomer_7″ 
              caption=”Insert DimCustomer” showIf=”immediate”></xsf:button>
      </xsf:menuArea>
    </xsf:view>
  </xsf:views>
  <xsf:applicationParameters application=”InfoPath Design Mode”>
    <xsf:solutionProperties 
      fullyEditableNamespace=”http://schemas.microsoft.com/office/
                              infopath/2003/myXSD/2007-03-19T15:02:59″ 
      lastOpenView=”view1.xsl” 
      lastVersionNeedingTransform=”1.0.0.3″></xsf:solutionProperties>
  </xsf:applicationParameters>
  <xsf:documentSchemas>
    <xsf:documentSchema rootSchema=”yes” 
       location=”http://schemas.microsoft.com/office/infopath/2003/
                 dataFormSolution schema.xsd”></xsf:documentSchema>
    <xsf:documentSchema 
       location=”http://schemas.microsoft.com/office/infopath/2003/ado/
                 dataFields schema1.xsd”></xsf:documentSchema>
    <xsf:documentSchema 
       location=”http://schemas.microsoft.com/office/infopath/2003/ado/
                 queryFields schema2.xsd”></xsf:documentSchema>
  </xsf:documentSchemas>
  <xsf:fileNew>
    <xsf:initialXmlDocument caption=”Unpacked” 
       href=”template.xml”></xsf:initialXmlDocument>
  </xsf:fileNew>
  <xsf:query>
    <xsf:adoAdapter connectionString=”Provider=SQLOLEDB.1;Integrated Security=SSPI;
                           Persist Security Info=True;Initial Catalog=AdventureWorksDW;
                           Data Source=[Source];Use Procedure for Prepare=1;
                           Auto Translate=True;Packet Size=4096;Workstation ID=[ID];
                           Use Encryption for Data=False;
                           Tag with column collation when possible=False” 
           commandText=”select &quot;CustomerKey&quot;,&quot;Title&quot;, 
                        &quot;FirstName&quot;,&quot;MiddleName&quot;,
                        &quot;LastName&quot;,&quot;BirthDate&quot;,
                        &quot;MaritalStatus&quot;,&quot;Suffix&quot;,
                        &quot;Gender&quot;,&quot;EmailAddress&quot;,
                        &quot;AddressLine1&quot;,&quot;AddressLine2&quot; 
                        from &quot;dbo&quot;.&quot;DimCustomer&quot; 
                        as &quot;DimCustomer&quot;” 
           queryAllowed=”yes” name=”Main connection” 
           submitAllowed=”no”></xsf:adoAdapter>
  </xsf:query>
</xsf:xDocumentClass>
The xsf:extensions element is used to bind the form to other platforms, like SharePoint.
>What are the Form View files in InfoPath? Or XSL files?
The .xsl file is the form view file that provide a way to represent different information, depending upon the runtime environment and other factors, including the security profile of end users. They are based on XML stylesheets that can be formatted depending upon the condition. [Conditional formatting is itself an inbuilt property of XSL.]
>What is an .XSD file in InfoPath?
It is the form schema file of InfoPath. It determines the format of data that InfoPath recognizes.
>Where does data get stored in an InfoPath form?
Data is stored in XML files.
>Explain in brief the architecture of InfoPath forms?
An InfoPath form template is actually a CAB File containing different component files.
Below is a list of files which forms part of an InfoPath template.
•.xsf file: A manifest file that describes the basic definition of other form files.
•.xsl file: Defines the transformation for data into different views.
•.xsd file: Defines the data source schema.
•.dll file: Carries the custom logic built into .NET or COM.
•.htm and other resource files: Custom HTML resource files and other resources for the form.
When a form template is uploaded using Administrative deployment, the template is stored in the content database of the site. Office Forms Services provide a server-runtime environment for InfoPath Forms Services. While running on the browser, all rules, validations, and calculations are executed in the browser using client-side script.
All business logic is executed on the server. So when a browser requests business logic execution, a postback is executed using low cost XMLHTTP. FormsServer.aspx is an Infopath Forms Services page that accesses the form’s data from the content database and renders it to the client.
>What are the main components of InfoPath Form Services that are responsible for rendering the .xsn file on browsers?
The InfoPath Form Services consists of four components that are responsible for rendering the .xsn file on browsers:
1.ASP.NET modules: Return HTML to the browser.
2.Infopath Form Services HTTPHandlers: Forward requests from IIS to the page generator.
3.Converter: Responsible for converting the .xsn file into .aspx pages.
4.Page generator: Communicates with internal data sources, and is responsible for processing postback data from the browser and maintaining session states.
>What are the steps to create a Template Part?
In the Design a Form dialog box, you can choose to design a template part instead of a form template. If you do this, InfoPath features that aren’t supported in template parts are either hidden or disabled so that you aren’t tempted to use them in your template part.
1.On the File menu, click Design a Form Template.
2.In the Design a Form Template dialog box, click Template Part.
3.In the Based on gallery, do one of the following:
?To define the data source (Data source: the collection of fields and groups that define and store the data for an InfoPath form. Controls in the form are bound to the fields and groups in the data source.), as you design the template part, click Blank.
?To use an XML document (.xml) file or an XML schema (XML schema: A formal specification, written in XML, that defines the structure of an XML document, including element names and rich data types, which elements can appear in combination, and which attributes are available for each element.) (.xsd) file as the data source for the template part, click XML or Schema.
Note: If you base your template part on an XML document or XML schema, InfoPath populates the Data Source task pane with fields (field: an element or attribute in the data source that can contain data; if the field is an element, it can contain attribute fields; fields store data that is entered into controls) and groups (group: an element in the data source that can contain fields and other groups; controls that contain other controls, such as repeating tables and sections, are bound to groups) that map to XML elements (XML element: an XML structure that consists of a start tag, an end tag, and the information between the tags; elements can have attributes and can contain other elements) in the document or schema. The data source is locked. Depending on the document or schema, you might not be able to add new fields or groups to part or all of the data source, or to change certain aspects of existing fields and groups.
?To make your template part compatible with InfoPath Forms Services, select the Enable browser-compatible features only check box.
?Click OK.
A new template part opens in InfoPath.
?Design your template part.
?When you finish designing the template part, on the File menu, click Save.
How to reuse Template Parts
If you want to base the design of a new template part on an existing template part, you must open the existing template part, change its name in the Template Part Properties dialog box, and then save the new template part with another, distinguishing file name. When you change the template part name in the Template Part Properties dialog box, the template part ID is updated automatically. This ID further distinguishes one template part from another.
1.On the File menu, click Design a Form Template.
2.Under Open a form template in the Design a Form Template dialog box, click On My Computer.
3.In the Files of type list, click InfoPath Template Parts.
4.Browse to and click the template part that you want to open, and then click Open.
5.On the File menu, click Properties.
6.In the Template Part Properties dialog box, enter a new name in the Template part name box.
When you do this, the identifying text in the Template part ID box reflects the new name. The template part ID is generated automatically by InfoPath. It must be unique for each new template part that you create.
7.On the File menu, click Save As, and enter a new file name for the template part.
What is Document Information Panel?
When you create a document with Office Word 2007, Office Excel 2007, or Office PowerPoint 2007, a Document Information Panel is created for you automatically. This default Document Information Panel includes standard properties, such as Author, Title, and Subject. Alternatively, you can add custom properties by designing a Document Information Panel from scratch and then associating it with a document, or by customizing an existing Document Information Panel.
A document information panel is a form that is displayed within the client application, and which contains fields for the document metadata. Document information panels enable users to enter important metadata about a file anytime they want, without having to leave the Microsoft Office system client application.
>How many sections are there inside the InfoPath Form Services element?
There are five sections:
1.Manage Form Templates
2.Configure InfoPath Services
3.Upload form templates
4.Manage Data Connection files
5.Manage the Web Service proxy
>How is form session state maintained?
The InfoPath Form Services can maintain data in two modes:
1.SQL Server database: This approach is termed as using Session State Services.
2.ASP.NET view states stored in the client side: Termed form view.
Points to be noted: The application needs to be associated with the Shared Service Provider.
>When to use which session state mode?
Session State Service mode [SQL Server database] is recommended for low bandwidth users, as the form view states hamper the performance for low bandwidth. Whereas, Form View can be used for environments with small groups of users.
The administrator can also enter a value for the session data size allowed for Form View State. InfoPath Form Services will automatically revert to Session State Service when session data size exceeds the value associated with the form view mode.
Q. How do I retrieve the value of an InfoPath field through code?
Ans.
XPathNavigator nav = MainDataSource.CreateNavigator();
string fieldValue = nav.SelectSingleNode("//my:field1", NamespaceManager).Value; 

Q. How do I set the value of an InfoPath field through code?
Ans.
XPathNavigator nav = MainDataSource.CreateNavigator();
nav.SelectSingleNode("//my:field1", NamespaceManager).SetValue("myValue"); 

Q. How do I call a web service through code?
Ans.
// Create an XPathNavigator object to navigate the data source of the web service
XPathNavigator nav = DataSources["HelloWorld"].CreateNavigator();

// Set the value of the parameter to pass to the web service
nav.SelectSingleNode("//dfs:queryFields/tns:HelloWorld/tns:name", NamespaceManager).SetValue("myValue");

// Call the web service
DataSources["HelloWorld"].QueryConnection.Execute(); 
// Retrieve the results returned by the web service
string results = nav.SelectSingleNode("//dfs:dataFields/tns:HelloWorldResponse/tns:HelloWorldResult", //NamespaceManager).Value;
//where HelloWorld is the name of a data connection to a web service.

Creating a SharePoint Form with InfoPath Designer


  • SharePoint List: Use this template to generate an interface for interacting with a SharePoint list. The generated form can create the actual list in SharePoint.
  • SharePoint Form Library: Use this template to generate a form library that stores instances of your form from user input. The content type of this form library is your form template.
  • E-mail: Use this template to generate a form that can be used within emails.
  • Blank Form: This is the base web browser form template used to generate SharePoint forms from scratch.
  • Blank Form (InfoPath Filler): This base client form template is used to generate forms that require users to have InfoPath installed locally on their computers. The forms created using this template are not rendered in a web browser.
  • Database: Use this template to quickly create a form based on a database table from Access or SQL Server.
  • Web Service: Use this template to generate a form that queries a web service for information.
  • XML or Schema: This template is used to easily replicate the data structure of an XML file or schema (XSD).
  • Data Connection File: Use this template to quickly generate a form that uses a data connection file stored in SharePoint.
  • Convert Existing Form: The name is confusing, because you would think this is used to convert an existing InfoPath form, but this template actually uses converters to import Microsoft Word or Microsoft Excel documents and convert them into InfoPath forms.
  • Document Information Panel: InfoPath now makes it easier to customize input into Office documents based on SharePoint columns. Use this template to generate the data entry portion of a Microsoft Office document that is stored within a SharePoint library and contains additional fields for user entry.
  • Blank 2007 Form: Use this form to create a web-based InfoPath 2007 form.
How to Publish an InfoPath 2010 form to Form Library in SharePoint 2010

When you are finished designing a form template, you must publish it so that users can fill out forms based on the form template.

While publishing an InfoPath form, we have multiple options available such as
1)     Quick Publish: Publish form to current location
2)    SharePoint Server: Publish form to a SharePoint Library
3)     E-mail: Publish form to a list of e-mail recipients
4)    Network Location: Publish form to a network location or file share

In this part, we will see How to publish an InfoPath form to a SharePoint Library
Please refer the step by step details and your form will be published to the SharePoint library without any problems:
  • Click File.
  • Click Publish.
  • Click SharePoint Server


  • Enter the Web address of the SharePoint site in the text box.
  • Click Next
  • Select how to publish the form
  • Select Form 
  • Click Next
  • Click a pre-existing form library for the InfoPath form if one has already been created or click Create a new form library to create a new one.
  • Click Next
  • If you are creating a new SharePoint library, enter the name of the library in the Name text box and a description for the library in the Description text box.
  • Click Next
  • To display data from your form as a column in the form library, use property promotion. To do this, click Add, select a desired field, and then type a name for the column in the Column name box.
  • If you selected a repeating field, click a value in the Function list to define how to display the field in the form library, and then click OK.
  • Click Next.
  • Click Publish.
If you have any queries/questions regarding the above mentioned information then please let me know. I would be more than HAPPY 2 HELP AS WELL AS RESOLVES UR ISSUES


References:

No comments:

Post a Comment