Symptoms
I have a process instance that uses InfoPath integration and one of the fields is a people picker. Unfortunately, this workflow has been open for a long time, and during that time the user account is no longer active. I'm trying to chase down users with open workflows to get them closed and, in this case, the approver can't approve the form due to form validation not accepting the invalid user. If this was a normal InfoPath form, I'd just change the XML, but since the XML is stored in the k2 DB I am uncertain how to resolve this.
Diagnoses
Unfortunately, data fields/XML fields are not stored "as is" in the K2 database (the API encodes them) as such making changes via the database is difficult/not recommended.
1. One way that we can perhaps update a data field/XML field for an active process instance is to perhaps use the "SourceCode.Workflow.Client" API to update a datafieldXML field as per:
http://community.k2.com/t5/K2-blackpearl/How-to-update-ActivityInstanceDestination-DataFields/td-p/19161/page/2
* you will likely need to use an account with Process Admin rights
* and use code similar to:
Connection.Open(connectionString)
WorklistItem worklistItem = Connection.OpenWorklistItem(serialNumber, "ASP", true, true)
worklistItem.ProcessInstance.DataFieldsd"Task"].Value = "Test" // This gets saved
worklistItem.ProcessInstance.XmlFieldsd“ECMInput”].Value = xmlDoc.OuterXml
worklistItem.ProcessInstance.Update()
worklistItem.Release()
Connection.Close()
2. I believe there may be some tools on the K2 Community site that may provide a starting point:
a. http://community.k2.com/t5/General-K2-Utilities/Process-Instance-Data-Fields-Editor/ba-p/82810
b. https://code.google.com/p/k2-datafield-editor/downloads/list
** this second one seems to also include XML update codes
Please note that these projects on K2 Community are community-based and have not been tested/supported by K2. Please test this in a development esting environment and make any necessary changes before implementing in production.
Resolution
Customer was able to use the third-party tool found at the location below to update the Infopath process XML:
https://code.google.com/p/k2-datafield-editor/downloads/list
In order for the Infopath client event task form to reflect the XML data field update, a GotoActivity was performed to the same Activity containing the current Infopath client event.
Please also consider if the process was designed in a way such that you can perform a GotoActivity to that same activity without adverse effect. As there are certain considerations when performing a GotoActity, such as:
- parallel activities/tasks
- If the Goto activity action is performed, all active and running state activities and lines will expire and any further executions will cease before the process will go to the activity as specified
- Data Field and XML Field values are not rolled back when going back to an activity that is prior to where the Data Fields or XML Fields have been set. If Line Rules are dependent on the Value of the Data Field or XML Field, the Rule might evaluate differently than expected.
- If any errors are received in the process, the entire process will be marked as in Error state, and all other executions will be stopped on all branches of the process. If you would like to perform a Goto Activity from the error state, please consider the above points carefully. In some cases, it would be better to perform an error retry or repair the error rather than to perform the Goto activity action
https://help.k2.com/onlinehelp/k2blackpearl/userguide/current/webframe.html_reference-ws_mcon-workflow-procinstancegotoact.html
Please test thoroughly before implementing as this is an unsupported tool and performing a GotoActivity requires special considerations.