How do I access the data submitted from the workflow federation form?

How do I access the data submitted from the workflow association form?

Scenario: When an administrator associates a workflow with a list of common names, I want to display an infopath form that allows you to set variables that apply to all instances in that list. The association form appears as I expect and it sends the data entered back to the hosting environment. I read that I can get the data once inside an instance workflow via SPWorkflowActivationProperties.ActivationData, but this is an xml string. Is it not possible to access the returned data through extended properties in the same way as what you do with normal infupata forms?

+1


source to share


1 answer


As far as I know, this is not possible with InfoPath OOTB. However, most of my experiences with custom initiation forms have used ASP.NET Web Forms where we serialized the class and added it to ActivationData.

Possible approaches:

  • Encapsulate XML Parsing

  • Use xsd.exe to create a class based on the schema of your infopath form.

1. Encapsulate XML Parsing

You can create a class that encapsulates your form data and takes an xml string as a constructor parameter.



Infopath form:

<?xml version="1.0" encoding="UTF-8"?><?mso-infoPathSolution solutionVersion="1.0.0.2" productVersion="12.0.0" PIVersion="1.0.0.0" href="file:///C:\Documents%20and%20Settings\Administrator\My%20Documents\Template1.xsn" name="urn:schemas-microsoft-com:office:infopath:Template1:-myXSD-2005-10-21T21-12-27" ?><?mso-application progid="InfoPath.Document" versionProgid="InfoPath.Document.2"?><my:assetTracking xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2005-10-21T21:12:27" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003" xml:lang="en-gb">
<my:employee>
    <my:employeeName></my:employeeName>
    <my:employeeDepartment></my:employeeDepartment>
</my:employee>
<my:assets>
    <my:asset>
        <my:assetID></my:assetID>
        <my:assetDescription></my:assetDescription>
        <my:assetMake></my:assetMake>
        <my:assetModel></my:assetModel>
        <my:assetSerialNumber></my:assetSerialNumber>
        <my:assetAssignedTo></my:assetAssignedTo>
        <my:assetDepartment></my:assetDepartment>
        <my:assetLocation></my:assetLocation>
        <my:assetCategory></my:assetCategory>
        <my:assetNotes></my:assetNotes>
    </my:asset>
</my:assets>

      

Custom Form Data Class

public class FormData
{

  public string EmployeeName { get; set; }
  public string EmployeeDepartment { get; set; }

  public FormData(string formData)
  {
       XmlDocument document = new XmlDocument();
       document.LoadXml(formData);
       XmlNamespaceManager namespaceManager = new XmlNamespaceManager(document.NameTable);
       namespaceManager.AddNamespace("my", "http://schemas.microsoft.com/office/infopath/2003/myXSD/2007-05-08T04:21:20");

       // Initialize member fields
       this.EmployeeName = document.SelectSingleNode("/my:employee/my:employeeName", nsmgr).InnerText;
       this.EmployeeDepartment = doc.SelectSingleNode("/my:employee/my:employeeDepartment", nsmgr).InnerText;

       etc....
  }
 }

      

2. Use xsd.exe xsd can be used to create a class based on the schema used by your workflow form. See: How to Access Association and Form Initiation Data in a Workflow

+2


source







All Articles