HOW TO: Develop a workflow code activity in SharePoint 2013
This post is a contribution from Raghavendra B Nanjaiah, an engineer with the SharePoint Developer Support team.
First part is to create our code activity and let the Workflow Manager and SharePoint 2013 know about it.
1. In VS 2012, click New Project, Workflow and choose Activity Library.
2. Delete the declarative Activity1.xaml from the solution since we will be creating our own custom code activity.
3. In solution explorer on newly created activity library right click and select add new item -> Workflow -> Code Activity.
4. Decide what data you would like to pass in to custom activity. In my case I am accepting string as InArgument and trying to create new list item based on the input string parameter (you can also use OutArgument which represents the flow of data out of an activity).
5. Write your activity logic in overridden execute method.
6. Build the Project and sign the code activity assembly.
7. Now, Create a new xml file and name it as AllowedTypes.xml and add the reference of you activity library dll , Namespace and type as shown below ( this basically adds your assembly to whitelist which Workflow service trust and loads. If your assembly is not in whitelist you might receive activity not found exception)
8. Now it's time to deploy our assembly and allowedtypes.xml to the folder from where Workflow manager and SharePoint can read.
* On the Workflow Manager box you have to:
- Copy activity assembly to following locations:
> %ProgramFiles%\Workflow Manager\1.0\Workflow\Artifacts
> %ProgramFiles%\Workflow Manager\1.0\Workflow\WFWebRoot\bin
- Add your activity class to the white-list
> Copy AllowedTypes.xml also to above two locations
- Restart “Workflow Manager backend” service
* On SharePoint box you have to:
- Copy activity assembly to SharePoint box and install it in the GAC.
- Reset IIS
Now, the second part is to create a workflow using custom code activity that we created by following the above steps.
1. Now in the same visual studio solution where you have custom code activity add new SharePoint 2013 Workflow project.
2. From the toolbox drag and drop the custom code activity that we just developed.
3. Right click and deploy the solution to your SharePoint site.
Bingo! Now we have developed and deployed custom code activity Workflow in SharePoint 2013 with Workflow Manager 1.0.
Hope this helps!
Comments
Anonymous
January 01, 2003
I can not find the Sharepoint 2013 Workflow Project Template in either VS 2010 or in VS 2013, can you provide a little more guidance on this? thanks.Anonymous
January 01, 2003
@dlr442218: Download and install SharePoint 2013 development tools from here: msdn.microsoft.com/.../fp123627.aspx. Click "Download the tools" in the section "Microsoft Office Developer Tools for Visual Studio 2012".Anonymous
January 01, 2003
ThanksAnonymous
January 01, 2003
very good i use your post to create my our Custom ActivitiesAnonymous
January 01, 2003
Please try VS2012!Anonymous
January 01, 2003
Very useful post!!! Thanks a lot.
Can you describe me how can i use may code activity in other sharepoint project. Its not visible in Tools window any if i add my custom activity dll from GAC.
Many Thanks.Anonymous
October 08, 2013
The comment has been removedAnonymous
October 24, 2013
The comment has been removedAnonymous
November 15, 2013
The comment has been removedAnonymous
December 03, 2013
The steps for writing .actions4 file are missing.Anonymous
July 07, 2014
Beware that this will not work in SharePoint OnlineAnonymous
July 07, 2014
Beware that this will not work in SharePoint OnlineAnonymous
August 18, 2014
This is a problematic solution. Manually copying files to a workflow server is problematic, as a new server could be added to the farm at any point, at which point the workflow is broken until the dlls are copied over.Anonymous
September 23, 2014
Horrible approach with the need for manual copying dlls etc.
Thanks for throwing us 10 years back in time Microsoft!
I'll stick to a web service approach, which is not ideal, but at least not as horrible as the approach described on this page.Anonymous
November 10, 2014
Thanks, very helpful. Just one question, I modified my code activity and rebuild it, but now i have three locations where my dll was deployed. What's the correct deploy step?Anonymous
November 25, 2014
If the custom code activity has some functionality written which will use object model of sharepoint, then will all WFM servers need to have WFE role?Anonymous
December 04, 2014
This cannot be the only way to run C# from a workflow in SharePoint 2013??? If it is I will be sticking with Sequential workflows and dealing with the obsolete warnings.Anonymous
December 23, 2014
The comment has been removed- Anonymous
May 31, 2017
Hi,did you resolve the issue ,I have the same issue ,but not yet resolved, if you have resolved then please share the solution.Thanks
- Anonymous
Anonymous
March 05, 2015
Information was good, I like your post.
Looking forward for more on this topic.
http://staygreenacademy.com">SharePoint 2013 Development training OnlineAnonymous
April 09, 2015
Hi Des,
I don't know if it is too late, but I was having the same issue even with the latest SharePoint Server 2013 upgrade.
What I did is to compare the "workflow.xaml" file from a SharePoint Designer workflow (after having saved it as a template into the Site Assets library) with the "workflow.xaml" generated from within Visual Studio 2013. What I found and what resolved my issue is to add these two attributes as a part of the Activity element.
xmlns:local
="clr-namespace:Microsoft.SharePoint.WorkflowServices.Activities"
xmlns:mwaw
="clr-namespace:Microsoft.Web.Authoring.Workflow;assembly=Microsoft.Web.Authoring"Anonymous
July 02, 2015
Instead of moving on to step two where you create a workflow in Visual Studio, can you instead use these actions from within Sharepoint Designer to make workflows?Anonymous
July 02, 2015
How do I save a workflow as a template and get a .xaml file? By default when saving as a template the workflow is saved as a .wsp file, which I can't really examine to add the tags you mentioned.Anonymous
August 18, 2015
What an amazing number of totally automatable steps to create a code activity that you can use! Way to over complicate things MS - "programming" in .NET is more menu surfing and config file fiddling than coding.Anonymous
August 31, 2015
The comment has been removedAnonymous
August 31, 2015
The comment has been removedAnonymous
November 27, 2015
Thanks for the great info. I really loved this. I would like to apprentice at the same time as you amend your web site, how could i subscribe for a blog site?
For more info on showbox please refer below sites:
http://showboxandroids.com/showbox-apk/
http://showboxappandroid.com/
Latest version of Showbox App download for all android smart phones and tablets. http://movieboxappdownloads.com/ - It’s just 2 MB file you can easily get it on your android device without much trouble. Showbox app was well designed application for android to watch movies and TV shows, Cartoons and many more such things on your smartphone.
For showbox on iOS (iPhone/iPad), please read below articles:
http://showboxappk.com/showbox-for-ipad-download/
http://showboxappk.com/showbox-for-iphone/
Showbox for PC articles:
http://showboxandroids.com/showbox-for-pc/
http://showboxappandroid.com/showbox-for-pc-download/
http://showboxforpcs.com/
There are countless for PC clients as it is essentially easy to understand, simple to introduce, gives continuous administration, effectively reasonable. it is accessible at completely free of expense i.e., there will be no establishment charges and after establishment it doesn't charge cash for watching films and recordings. Not simply watching, it likewise offers alternative to download recordings and motion pictures. The accompanying are the strides that are to be taken after to introduce Showbox application on Android. The above all else thing to be done is, go to the Security Settings on your Android telephone, Scroll down and tap on 'Obscure sources'.Anonymous
May 31, 2017
The comment has been removedAnonymous
July 13, 2017
I am getting below error while adding the code activity to sharepoint online site.Cannot create unknown type '{clr-namespace:ReviewWorkflow}CodeActivity1'.Please help on this..Anonymous
November 08, 2017
(The content was deleted per user request)Anonymous
July 09, 2018
Nice, thanks ))