Skip to main content

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;
            }

Is your activity a parallel one??

Is your Server Event (that contains the above code) in the same Activity as the InfoPath Client Event?  If so, that is most likely the issue.  With InfoPath integrated K2 processes, the the InfoPath schema in process level XML field is copied to Activity level XML field that has the same name and schema.  The InfoPath client event actually uses the Activity level field.  Once the activity is complete, an Activity with an InfoPath client event then has logic built into the Activity Succeeding Rule to reverse the above logic and copy the Activity level XML field up to the Process level XML field.

HTH.


Yes, the destination planning is as follows...


- plan per destination


- plan all at once


- create a slot for each destination


- resolve all roles and groups to users


- succeeding rule of At least 1 slot = complete (in order to allow multple users to open their task at the same time, but only one may complete it)


Hi Bob


Thanks for the reply...Yes, my server event is within a activity that also contains an infopath event, it is just after it. This activity will be for the user whom should be able to change and resubmit a task that was rejected by other users.


So you are saying this will work if I rather put the server event in a seperate activity that does not contain an infopath client event? I will give that a try.


What are other possible solutions...I suppose using either process data fields, or activiy data fields to store the comments of each approver and then updateing the form xml fields with the values.


Will let you know what happens.


 


Hurahh! Putting the server event in a seperate activity did the trick!! The xml action and commment fields are now cleared from the second and onwards approval iteration.


Thanks for the help "-)


Reply