How to create custom action for workflow in share point 2013
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

How to create custom action for workflow in share point 2013

on

  • 1,117 views

In this slide we have created a custom action for a Microsoft SharePoint 2013 workflow.

In this slide we have created a custom action for a Microsoft SharePoint 2013 workflow.

Statistics

Views

Total Views
1,117
Views on SlideShare
1,115
Embed Views
2

Actions

Likes
0
Downloads
9
Comments
0

2 Embeds 2

http://pinterest.com 1
http://www.pinterest.com 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft Word

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

How to create custom action for workflow in share point 2013 Document Transcript

  • 1. Flexmind Solutions www.flexmindsolutions.com Email: support@flexmindsolutions.comContact: 080- 41115849 Steps to Create a Custom Action for Workflow in SharePoint 2013 [WF4] Download: The solution can be downloaded from Microsoft Technet Gallery here: http://gallery.technet.microsoft.com/Create-Query-XML-workflow-70c8369b Action Name: - Build XML Document Purpose: - To generate the XMLDocument object from the given XML input as a string. Arguments Type InArgument /XMLString String OutArgument /XMLDOcument XMLDocument Steps:- 1) Create the VSTS 2010 empty solution. 2) Create new Workflow code activity project, select the frame work version 4. 3) Give the name of code activity file as BuildXMLDocument.cs 4) Open the code file 5) Declare one input argument and one output argument publicInArgument<String>XMLString { get; set; } publicOutArgument<XmlDocument>XMLDocument { get; set; } 6) In execute method, place the below code protectedoverridevoid Execute(CodeActivityContext context) { // Obtain the runtime value of the Text input argument StringXMLString = context.GetValue(this.XMLString); byte[] byteArray = Encoding.ASCII.GetBytes(XMLString); XmlDocumentxmldoc = newXmlDocument(); using (MemoryStream stream = newMemoryStream(byteArray)) { xmldoc.Load(stream); } XMLDocument.Set(context, xmldoc); } 7) Build the solution. Now you can find your activity in the VSTS tool box
  • 2. Flexmind Solutions www.flexmindsolutions.com Email: support@flexmindsolutions.comContact: 080- 41115849 Action Name: - Query XML Data Purpose: - To query the XML using XPath, result output as collection of string, or return the single text value Arguments/Parameter Types InArgument / XMLData XMLDocument InArgument / XPathQuery String OutArgument / Value String OutArgument / MultiValue System.Collections.Generic.IList<String> Steps: 1) Add new item to the existing project, workflow code activity name it as QueryXMLData.cs. 2) Declare argument as publicInArgument<XmlDocument>XMLFileData { get; set; } publicInArgument<String>XPathQuery { get; set; } publicOutArgument<String> Value { get; set; } publicOutArgument<System.Collections.Generic.IList<String>>MultiValue { get; set; } 3) Execute method protectedoverridevoid Execute(CodeActivityContext context) { // Obtain the runtime value of the Text input argument XmlDocumentXMLDoc= context.GetValue(this.XMLFileData); StringXPathQuery = context.GetValue(this.XPathQuery); Value.Set(context, string.Empty); // Dictionary<string, string>multivalue = new Dictionary<string, string>(); IList<String>multivalue = newList<string>(); XmlNodeList _xmlNameSpaceList = XMLDoc.SelectNodes(@"//namespace::*[not(. = ../../namespace::*)]"); XmlNamespaceManager _xmlNSmgr = newXmlNamespaceManager(XMLDoc.NameTable); // Read all the name space in the XML foreach (XmlNodensNodein _xmlNameSpaceList) { // Console.WriteLine(nsNode.LocalName + " " + nsNode.Value);
  • 3. Flexmind Solutions www.flexmindsolutions.com Email: support@flexmindsolutions.comContact: 080- 41115849 if (nsNode.LocalName.ToLower() != "xmlns") _xmlNSmgr.AddNamespace(nsNode.LocalName, nsNode.Value); else _xmlNSmgr.AddNamespace("def", nsNode.Value); } XmlNodeListnodelist = XMLDoc.SelectNodes(XPathQuery, _xmlNSmgr); ///catalog/cd[price>10.0] //cd[@country='UK'] //catalog/cd/title //def:ProjectDataSet/def:Assignment/def:PROJ_UID if (nodelist.Count> 1) { // intiPos = 0; foreach (XmlNodeisbninnodelist) { //multivalue.Add(iPos.ToString(), isbn.InnerText); multivalue.Add(isbn.InnerText); // iPos++; } MultiValue.Set(context, multivalue); } elseif (nodelist.Count == 1) { foreach (XmlNodeisbninnodelist) { Value.Set(context, isbn.InnerText); } } } 4) Build the project, verify the activity appear in VSTS tool box 5) Now we will create the workflow using above activity we build 6) Open the Activity.xamlfile , place the activity from VSTS tool box.
  • 4. Flexmind Solutions www.flexmindsolutions.com Email: support@flexmindsolutions.comContact: 080- 41115849 7) Create 2 input parameter 8) Create variables 9) Set the input and output parameter for BuildXMLDocument activity
  • 5. Flexmind Solutions www.flexmindsolutions.com Email: support@flexmindsolutions.comContact: 080- 41115849 10) Similarly set the property forQueryXMLData 11) Place the foreach action to iterate through the collection 12) Build the project 13) To test the workflow, create the workflow console application, add the reference of the workflow project created above. Dictionary<string, Object> param2 = newDictionary<string, object>(); param2.Add("InputXML", @"<?xml version='1.0' ?> <catalog> <cd country='USA'> <title>Empire Burlesque</title> <artist>Bob Dylan</artist>
  • 6. Flexmind Solutions www.flexmindsolutions.com Email: support@flexmindsolutions.comContact: 080- 41115849 <price>10.90</price> </cd> <cd country='U'> <title>Hide your heart</title> <artist>Bonnie Tyler</artist> <price>10.0</price> </cd> <cd country='USA'> <title>Greatest Hits</title> <artist>Dolly Parton</artist> <price>9.90</price> </cd></catalog>"); param2.Add("Xpath", @"//catalog/cd/title"); // param.Add("Subject", ""); IDictionary<string, Object> param3 = WorkflowInvoker.Invoke(new QueryXMLData.Activity1(), param2); Our Office Address: Flexmind Solutions Pvt Limited 17 Main 7 Cross, BTM 2nd Stage Bangalore,India. Website: www.flexmindsolutions.com Email: support@flexmindsolutions.com Phone: +91-080-41115849