This SharePoint tutorial we will discuss, how we can create a 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 a 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.
Create Workflow using Visual Studio 2015 for SharePoint Online
Follow the below steps to create workflows using visual studio 2015 as an add-in and deploy to host web in SharePoint online Office 365.
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 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 checkbox 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 asks 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 for 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 activity like below:
You may like following SharePoint workflow tutorials:
- SharePoint Online Video: Deploy SharePoint Designer Workflow into Production
- How to Trigger Sharepoint 2013 Designer workflow on a list item by calling REST API using jQuery?
- How to add edit task form URL inside SharePoint 2013 designer workflow email?
- How to send email to SharePoint group in visual studio 2015 workflow in SharePoint hosted add in SharePoint online?
- How to send email in visual studio 2015 workflow in SharePoint hosted add-in in SharePoint online?
- How to retrieve workflow id by using jsom in SharePoint online?
- SharePoint designer workflow examples: Steps to create a Leave Request SharePoint designer workflow in SharePoint Online
- SharePoint designer workflows: Create your First Workflow using SharePoint designer 2013
- Errors were found when compiling the workflow. The workflow files were saved but cannot be run error in SharePoint online designer workflow
Hope this will be helpful to create SharePoint online workflow using visual studio 2015/2017.
You May Also like the Following SharePoint Tutorials: