1

I need to get list of all the workflows using a custom activity.

I visited a workflow using designer and have the name of the activity.

I just need to read that xoml file and see whether that file contains the name of the custom activity or not.

I am able to get the workflow associations for the lists but do not know how to read the xoml file.

PS: SoapXML property of workflowassociation is not giving me the desired result.

1
  • 1
    So what result does SoapXml give then? Is it empty or missing some elements? Sep 6, 2014 at 12:02

1 Answer 1

2

You can try following code:

public static string 
  GetXOMLFromWorkflowInstance(SPListItem item, Guid wfInstanceId)
  {
    SPWorkflow wf = new SPWorkflow(item, wfInstanceId);
    SPWorkflowAssociation assoc = 
      item.ParentList.WorkflowAssociations[wf.AssociationId];

    XmlDocument doc = new XmlDocument();
    doc.Load(new StringReader(assoc.SoapXml));

    XmlNode node = doc.SelectSingleNode("/WorkflowTemplate");
    XmlAttribute attribute = node.Attributes["Name"];
    string wfName = attribute.Value.Replace(" ", "%20");            
    string webRelativeFolder = "Workflows/" + wfName;            
    string xomlFileName = wfName + ".xoml";

    SPFolder wfFolder = assoc.ParentWeb.GetFolder(webRelativeFolder);
    SPFile xomlFile = wfFolder.Files[xomlFileName];

    doc = new XmlDocument();
    using (Stream xomlStream = xomlFile.OpenBinaryStream())
    {
      doc.Load(xomlStream);
    }
    return doc.OuterXml;
  }

http://blog.krichie.com/2011/07/05/programmatically-reading-sharepoint-designer-workflow-xoml-files-at-run-time/

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.