I have a workflow that I would like to trigger from my Infopath 2007 form code. It has an Initiation parameter called RequestID that I would like to pass a value from my code.
My code submits the data to a SQL db via a web service and returns the RequestID which I store in a variable.
I can trigger the workflow without the parameter, but I need help updating that parameter with my variable.
Here is the code that gets my workflow information and triggers the startworkflow:
Public Shared Sub StartWorkflow(ByVal siteUrl As String, ByVal docUrl As String, ByVal workflowName As String, ByVal RequestID As Integer)
'Call Workflow.asmx Web ReferenceDim workflow As New Workflow.asmx.Workflow() workflow.Url = siteUrl & Convert.ToString("/_vti_bin/workflow.asmx")
'Set Credentials to Network Cache (Whichever user is currently logged in)
workflow.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials
'Get the available workflows for the document libraryDim assocNode As XmlNode = workflow.GetTemplatesForItem(docUrl)
Dim nsmgr As New XmlNamespaceManager(assocNode.OwnerDocument.NameTable)nsmgr.AddNamespace("wf", "http://schemas.microsoft.com/sharepoint/soap/workflow/")
Dim doc As New XmlDocument()Dim templateID As New Guid()
Dim workflowFound As Boolean = False
'Loop through the available workflows to find the relevant oneDim rows As XPathNodeIterator = assocNode.CreateNavigator().[Select]("//wf:WorkflowTemplate", nsmgr) While rows.MoveNext()
If rows.Current.GetAttribute("Name", "").ToLower() = workflowName.ToLower() Then doc.LoadXml(rows.Current.SelectSingleNode("wf:AssociationData/wf:string", nsmgr).Value)
Dim idNode As XPathNavigator = rows.Current.SelectSingleNode("wf:WorkflowTemplateIdSet", nsmgr) templateID = New Guid(idNode.GetAttribute("TemplateId", ""))
workflowFound =
True
Exit While
End If
End While
The InnerXML for doc includes the Parameter I set up in the workflow:
<dfs:myFields>
<dfs:queryFields />
<dfs:dataFields>
<d:SharePointListItem_RW>
<d:RequestID>0</d:RequestID>
</d:SharePointListItem_RW>
</dfs:dataFields>
</dfs:myFields>
But when I try and change the node inner text it doesn't recognise d:RequestID
nsmgr = New XmlNamespaceManager(assocNode.OwnerDocument.NameTable)
nsmgr.AddNamespace(
"my", "http://schemas.microsoft.com/office/infopath/2003/myXSD")Dim xmlRoot As XmlElement = doc.DocumentElementxmlRoot.SelectSingleNode("d:RequestID", nsmgr).InnerText = RequestID
Dim
workflowNode As XmlNode = workflow.StartWorkflow(docUrl, templateID, doc.DocumentElement)
The error I'm getting is namespace prefix d: is not defined. Have I got the wrong namespace?
Does the workflow expect the same format as above? How can I write to <d:RequestID>? I feel that I'm missing something quite simple here, but I have no idea what that may be.
I need to send this parameter as it will direct a user to a different form with the request data pre-filled from the DB based on the requestID parameter.
Jarred