I'm currently trying to develop a state machine workflow in VS2005. For this workflow I need 2 data sources:
- data from the current form item for that this workflow was started (it's an InfoPath document in a form library)
- and data from a specific dataset (can be identified by a specific field in the list) in another list on the website
How can I get access to this data I need it for the workflow to identify which user has to get a task assigned next and in the end I need the list to be updated with the results of the workflow.
Thanks in advance ;)

Accessing data in lists and libraries in a state machine workflow
CompuDav
Thanks for the reply, I will try that. I think, it will also help me, to solve my second question. I would just need an installation form, where you define the list library, so that I can access the content.
At the moment, I try to get my Workflow working with basic instructions, but I always get errors. But this will be discussed in another thread ;)
hohsen
Tried a bit around with NameSpaceManager and finally got it:
XmlNamespaceManager nsmgr = new XmlNamespaceManager(myDoc.NameTable);nsmgr.AddNamespace("my", http://schemas.microsoft.com/office/infopath/2003/myXSD/2007-02-08T14:19:55);
XmlNode node = myDoc.SelectSingleNode("//my:vertreter",nsmgr);
this.vertreter = new string[1];
this.vertreter[0] = node.FirstChild.Value;
node = myDoc.SelectSingleNode("//my:vorgesetzter",nsmgr);
this.vorgesetzter = node.FirstChild.Value;
node = myDoc.SelectSingleNode("//my:personalAbteilung",nsmgr);
this.personalAbteilung = node.FirstChild.Value;
John Clien
Hi Uwe82,
Not sure about the second point, but for the first, when I did this I did:
// Get the form ListItem in the Library
SPWeb myWeb = new SPSite(workflowProperties.SiteId).OpenWeb(workflowProperties.WebId);
SPListItem myItem = myWeb.Lists[workflowProperties.ListId].GetItemById(workflowProperties.ItemId);
// Read the SPFile into an XMLDocument
SPFile myFile = myItem.File;
Stream myStream = new MemoryStream(myFile.OpenBinary());
XmlDocument myDoc = new XmlDocument();
myDoc.Load(myStream);
// Read and use the XmlDocument as required...
Al-Arabi
Your code works, thanks!
But I have one problem, I'm trying to access the data inside via XPath-Expressions:
XmlNode node = myDoc.SelectSingleNode("//my:vertreter");this.vertreter = new string[1];
this.vertreter[0] = node.FirstChild.Value;
node = myDoc.SelectSingleNode("//my:vorgesetzter");
this.vorgesetzter = node.FirstChild.Value;
node = myDoc.SelectSingleNode("//my:personalAbteilung");
this.personalAbteilung = node.FirstChild.Value;
But with this, I get an XPathException: System.Xml.XPath.XPathException: Namespace Manager or XsltContext needed. This query has a prefix, variable, or user-defined function.
I never worked programmatically with XML-files with namespaces, so I don't know, how I can access the data, I want via XPath.
Do you have an idea