Premise: the Task Form is designed with InfoPath 2010.
Read data from ItemMetadata, the second data source, from the FormEvents_Loading event in Task Form. ItemMetadata contains rich data. In the workflow, store the xml data of RequestForm to the ows_ReqXMLSource field. Then, when you read the value of this field, we will find that not only the xml data of the Request, but also all the data associated with the Task (information such as Form Library and Task Id corresponding to the Request ).
String xmlSource = this. dataSources ["ItemMetadata"]. createNavigator (). outerXml; <br/> XmlDocument nodeDoc = new XmlDocument (); <br/> nodeDoc. loadXml (xmlSource); <br/> XmlNamespaceManager xnm = new XmlNamespaceManager (nodeDoc. nameTable); <br/> xnm. addNamespace ("z", "# RowsetSchema"); <br/> string myFields = nodeDoc. selectSingleNode ("/z: row/@ ows_ReqXMLSource", xnm ). value; </p> <p> XmlDocument document = new XmlDocument (); <br/> document. loadXml (myFields); <br/> XPathNavigator mainNav = this. mainDataSource. createNavigator (); <br/> XPathNavigator viewStateNode = mainNav. selectSingleNode ("/my: MyFields", NamespaceManager); <br/> viewStateNode. innerXml = node. innerXml; <br/>