Mutiple dynamic destinations from InfoPath

  • 18 November 2005
  • 2 replies
  • 4 views

Badge +1
I have the following problem: I would like to develop with InfoPath a solution in which in a process user chosses a list a people who should recieve an approval task in the following step. With a use of a repeating text field, InfoPath generates a part of XML as follows:
<my:Persons>
<my:Person>k2lab omek</my:Person>
<my:Person>k2labAdministrator</my:Person>
<my:Person>k2lableszek</my:Person>
</my:Persons>

So I have a list of domain logins in one XML group which I would like to use for specifing destinations for the next activity. It would be nice to dircetly use the "Activity Properties / Destination Rule" view and attach as a "Send to" a K2Field which represents the "Persons" group in a K2InfoPathSchema. Unfortunately this doesn't work because .Net code generated with this wizard adds only one entry for activity destination per one K2Field.

I could parse this XML "manually" but I have to prepare a solution which is possible to be developed by business user and has minimal coding.

To recap, the question is how can I set mutiple destinations, where destinations users are definded in a K2 XML Fields and without changing a standard code for destination rule?

Regards,

Tomasz

2 replies

Badge +9
Hi Tomasz,

The standard Destination Rule property template assumes that the selected data/xml field contains one value and does not cater for a repeating section with multiple users.

Your options are:

1. Edit the code after the code has been generated, as you explain this is not working for you as you want Business user to be able to define the worlflows

2. Develop a new Destination Rule Property template that can handle repeating sections in XML, this will be the more expensive option as you will need to spend some time developing + testing to insure that the property template is bug-free
Badge +1
My XML from Infopath looks something like this:

<destination_users>
<my:option xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2005-07-04T09:44:38">
<my:selected>true</my:selected>
<my:account>domain est1</my:account>
<my:name>John Smith</my:name>
</my:option>
<my:option xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2005-07-04T09:44:38">
<my:selected>true</my:selected>
<my:account>domain est2</my:account>
<my:name>Jane Smith</my:name>
</my:option>


Then I use this code to dynamically add destination users. I put this in the edit code section of the destination rule

Dim strXML As String
Dim stream As System.IO.StringReader
Dim reader As System.Xml.XmlTextReader
Dim acct

strXML = GetXMLValue1(K2.ProcessInstance.XmlFields("K2InfoPathSchema").Value, "my:myFields/my:options")
strXML = "<?xml version='1.0' encoding='UTF-8' ?><du>" & strXML & "</du>"


stream = New System.IO.StringReader(strXML)
reader = New System.Xml.XmlTextReader(stream)

While Not reader.EOF

If reader.NodeType = Xml.XmlNodeType.Element Then
If reader.Name = "my:selected" Then
reader.Read()
If reader.Value = "true" Then
reader.Read()
reader.Read()
reader.Read()
acct = reader.Value
If acct <> "" Then
K2.Destinations.Add(DestinationType.User, acct)
End If
End If
End If
End If
reader.Read()
End While

reader.Close

Reply