Follow in Twitter & Facebook

Like in Facebook

Powered By Blogger Widgets

Free Download

FREE Tools

Tuesday, July 25, 2017

SharePoint online visual studio workflow development step by step guide

Here we will discuss how we can create workflow using visual studio 2015 for SharePoint online site and also we will see how we can deploy to host web list or library. This is going to be a very simple workflow but we are going to understand how to do this with steps.

Since we are going to develop as an SharePoint hosted add-in, make sure you have a developer site is ready which you. You can check an article on how to create a developer site for SharePoint online Office 365.

Follow below steps:
Open visual studio 2015 and then File -> New -> Project. And then in the New Project dialog box, choose SharePoint Add-in from Templates ->Visual C# -> Office/SharePoint like below:

Then in the Add-in settings dialog box, give SharePoint online developer site url and choose the host type for SharePoint Add-in as "SharePoint-hosted".

Then it will ask for credentials to connect to SharePoint online site. Once entered successfully, it will show the below screen.

Now the SharePoint Add-in project will look like below:

To make the workflow available in the host web we need to choose "Integrated App" project properties to true. But since we have not added Workflow yet, you will not be able to see the "Integrated App" project properties.

Next we will add a the Workflow to the project. Right click on the Project, Add -> New Item. And in the Add New Item dialog box, choose Visual C# Items -> Office/SharePoint. And then choose Workflow template like below:

Then in the next screen, give a workflow name and choose List Workflow in the type of workflow like below:

Then in the Select the lists you will use when debugging screen, uncheck the check box and do not select anything like below:

Then the workflow will be added to the project and it looks like below:

Now click on F4 in the project to open the Project properties and there change the Integrated App property to True like below:

Now in the workflow search for a WriteToHistory action and click on the Message in the Properties box. There write some message as a string like below:

So this is a very simple workflow having one activity only. Now open the AppManifest.xml file and give Web to manage or full control permission like below:

Now we will try to publish the workflow to the SharePoint online site. Right click on the Project and click on Publish... like below:

This will open the Publish your add-in page, here click on Package the add-in which will generate the .app file like below:

Now we need to open the .app file using 7-zip or similar tool like below:

Then open the WorkflowManifest.xml file and check if the below tag is there or not.


If not add it and save the file.

Now it is the time to upload the .app file into the App Catalog site. Once it is uploaded to the App Catalog site, We can add into any SharePoint site, Site Contents > Add an App > Select your app and add it to your Team Site.

If it ask to trust, Trust it.

Now open any list and from the ribbon click on List Settings -> Workflow Settings and then click on Add a Workflow. In that screen you will see two options in Available Apps. One is for This List and another one as your App name (Here in my case it is ApprovalListWFHostWeb). In the Workflow details Click on the <Workflow Name>(in my case the name is ListApprovalWorkflow) like below:

Then give a name for the workflow and also you can select Task List & History List. Also choose the Start Options like when you want to start the workflow.

Now if you will again go back to the Workflow settings page, you can see the workflow is attached to the list like below:

Now it is time to start the workflow manually for one item in the list. For this select an item from the list, then click on ECB menu -> Advanced -> Workflows.

Then click on the workflow app and then you can see the workflow under Start a New Workflow like below:

Once the workflow got started successfully, you can see it will write the message which we have added inside the WriteToHistory activitity like below:

Hope this will be helpful.

0 on: "SharePoint online visual studio workflow development step by step guide"