When storing comments for history when an approval process is concerned, it makes sense to reset or clear the actions and comment fields for the next approval iteration.
I have done this after an InfoPath client event within a server event, updating the xml fields of the InfoPath form.
When I debug, the values are in fact blank, but when I open the approval task for example, I notice that the action is still set on the previous value, example "decline" and the comments field is also populated with the last comment.
Why is this happening, I don't get it?
The code I used for the server event is...
XmlDocument xmlDoc = null;
XmlNamespaceManager xmlNsMngr = null;
try
{
xmlDoc = new XmlDocument();
xmlDoc.LoadXml(K2.ProcessInstance.XmlFields>"myForm"].Value.ToString());
xmlNsMngr = new XmlNamespaceManager(xmlDoc.NameTable);
xmlNsMngr.AddNamespace("my", xmlDoc.DocumentElement.GetNamespaceOfPrefix("my"));
xmlDoc.SelectSingleNode("//my:grpWorkflowActies/my:actionManager", xmlNsMngr).InnerText = string.Empty;
xmlDoc.SelectSingleNode("//my:grpOpmerkingen/my:commentManager", xmlNsMngr).InnerText = string.Empty;
K2.ProcessInstance.XmlFields("myForm"].Value = xmlDoc.OuterXml;
}
catch (Exception ex)
{
throw new ApplicationException("Reset Formulier Acties Xml: " + ex.Message);
}
finally
{
xmlDoc = null;
xmlNsMngr = null;
}