I solved an interesting K2 error today that simply left the following message in the K2 Workspace and K2 Host Server logs
Key could not be found in the collection
K2 Automated Testing Software
BenchQA allows full test automation of K2, including fully automated K2 SmartForms and K2 Workflow testing. It promotes test driven development for K2 and ensures continued quality assurance for K2 solutions. Easily apply changes to test cases to accommodate changes to K2 apps and ensure all apps are regression tested to avoid defects and assure continuous quality.
Fortunately, K2 has a great feature whereby it moves erroneous processes into an error queue where they can be fixed and execution re-tried.
K2 Workspace – Key could not be found in the collection
I used the K2 ViewFlow tool and opened one of the live process instances that had the problem. This gave me a clue what K2 event threw the exception.
K2 blackpearl ViewFlow – Process in error stateThis clearly shows the Update Email Address K2 SmartObject failed and the error sounds like something that was not found. I thought a bit about it and concluded that perhaps a SmartObject property or SmartObject method was either missing or mismatched with the copy in QA and Development.
I used the K2 SmartObject tester and compared the versions of the SmartObject in QA and in Production. My hunch was correct. The Change Email Address K2 SmartObject method was missing in the production version.
K2 SmartObject Tester – Development and Production SmartObject MethodsThis has an extremely easy fix. Simply open K2 for Visual Studio and ensure the out-of-sync K2 SmartObject is selected and create a new deployment package.
K2 for Visual Studio – Create deployment packageCopy over to QA, deploy and inspect the K2 SmartObject to ensure the missing method is there now.
K2 SmartObject Tester – Development and Production SmartObject Methods in syncRepeat the K2 deployment process in production
K2 SmartObject Deployment – SuccessfulNow, re-open the erroneous K2 processes using K2 Worspace and retry the transactions. Notice all the errors disappeared.
Hopefully this will help you to troubleshoot any Key could not be found in the collection K2 errors. Note that in this instance a K2 SmartObject method was missing, but if you experience the same issue and all K2 SmartObject methods are indeed deployed, ensure all the K2 SmartObject Properties are in sync and that all data artefacts like stored procedures, views etc. are deployed.
This article demonstrates the strength of the K2 blackpearl product as well. Any errors gets caught by K2 Host Server and moved to a separate queue that allows troubleshooting, resolution and re-processing. This issue was fixed in production within an hour and the customer is extremely happy with the outcome.