SlideShare a Scribd company logo
1 of 6
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
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);
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.
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
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>
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

More Related Content

Recently uploaded

URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...RKavithamani
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 

Recently uploaded (20)

URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 

Featured

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationErica Santiago
 

Featured (20)

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 

How to create custom action for workflow in share point 2013

  • 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