CREATING A WORKFLOW IN SHAREPOINT INFOPATH FORMS

Aug 20, 2009 at 8:27 AM

CREATING A WORKFLOW IN SHAREPOINT INFOPATH FORMS

Step 1: Create an InfoPath form and publish the form in SharePoint

Procedure for publishing the form

  1.  Form options ->Compatibility
  2.  

 

public void Submit_Clicked(object sender, ClickedEventArgs e)

        {

            try

            {

               

                SqlConnection SqlConn = new SqlConnection("Your connectionString”);

                SqlCommand SqlComm;

               

                string strid;

string SampleId = this.MainDataSource.CreateNavigator().SelectSingleNode("/my:Sample1/my:Total_Estimated_Value", this.NamespaceManager).Value;

                             String Comm = "Insert into Sample1 values('" Sample1Value + "',);Select @@Identity;";

 

                SqlComm = new SqlCommand(Comm, SqlConn);

                if (SqlConn.State ==ConnectionState.Closed)

                 SqlConn.Open();

                TenderId= SqlComm.ExecuteScalar().ToString();      //.ExecuteNonQuery();

                if (SqlConn.State == ConnectionState.Open)

                SqlConn.Close();

 

                XPathNavigator Table_Sample = MainDataSource.CreateNavigator().SelectSingleNode("/my:Sample1/my:Sampletext/my:Sample", NamespaceManager);

 

  1. The Publishing wizard will open

 

  1. After  clicking next select the option “Enable this form to be filled out by using the browser”

 

 

 

 

 

CREATION OF WORKFLOW

 

 

 

  1.                              

 

  1. Workflow can be created by opening visual studio and clicking on the “Sharepoint server sequential workflow”

 

10.  Now we can get down to some coding! In the solution explorer double click on Workflow1.cs and up will open the workflow designer view. If you open up the toolbox you'll see three new groups of components, SharePoint - Workflow Tasks, SharePoint - Workflow, and Windows Workflow.

11.  As you can see on the Workflow1.cs design surface it already creates the first workflow step for us with a onWorkFlowActivated action. This will always be the first Workflow action of any workflow. Below this action is an arrow and a kind of stop sign. We can drag and drop any new workflow actions from the tool box and place them on the arrow. Before we do that though there are a few properties we can check before we get going. If you go into the code view of Workflow1.cs you’ll see

using System;

using System.ComponentModel;

using System.ComponentModel.Design;

using System.Collections;

using System.Drawing;

using System.Linq;

using System.Workflow.ComponentModel.Compiler;

using System.Workflow.ComponentModel.Serialization;

using System.Workflow.ComponentModel;

using System.Workflow.ComponentModel.Design;

using System.Workflow.Runtime;

using System.Workflow.Activities;

using System.Workflow.Activities.Rules;

using Microsoft.SharePoint;

using Microsoft.SharePoint.Workflow;

using Microsoft.SharePoint.WorkflowActions;

using Microsoft.Office.Workflow.Utility;

using System.Xml;

using System.Xml.Serialization;

 

namespace SharePointWorkflow1

{

    public sealed partial class Workflow1 : SequentialWorkflowActivity

    {

        public Workflow1()

        {

            InitializeComponent();

        }

 

        public Guid workflowId = default(System.Guid);

        public SPWorkflowActivationProperties workflowProperties = new SPWorkflowActivationProperties();

        public string field1 = default(string);

      

        private void onWorkflowActivated1_Invoked(object sender, ExternalDataEventArgs e)

        {

            SPListItem SPLISTSample = workflowProperties.Item;

            SPFile SPFileSample = SPLISTSample.File;

            XmlSerializer SampleSerializer = new XmlSerializer(typeof(myFields));

            XmlTextReader SampleReader = new XmlTextReader(SPFileSample.OpenBinaryStream());

            myFields SampleForm = new myFields();

            SampleForm = (myFields)SampleSerializer.Deserialize(SampleReader);

 

            field1 = SampleForm.field1;

            sampledatasetTableAdapters.sample1TableAdapter Sample_Adptr = new SharePointWorkflow1.sampledatasetTableAdapters.sample1TableAdapter();

            int SampleId = Convert.ToInt16(Sample_Adptr.Insert(field1));

         

        }

    }

}

  1. Here we have to add
  2. And write the above given code  when we run the work flow the workflow will be activated and the  project will be executed