Symptoms
Error when deploying K2 Workflow: System.NullReferenceException: Object reference not set to an instance of an object.
Diagnoses
Issue _ 1:
We're getting this error whenever we try deploying the workflow. Here is the rest of the error message:
System.NullReferenceException: Object reference not set to an instance of an object.
at SourceCode.Workflow.Authoring.K2FieldPartCollection.Add(K2FieldPart item)
at SourceCode.Workflow.Authoring.K2Field..ctor(K2FieldPartr] parts)
at SourceCode.Workflow.Design.Forms.FieldParts.FormPart..ctor(ArtifactLibraryFieldPart formsServerField, String formName, Guid formId)
at SourceCode.WebDesigner.Authoring.Forms.GenerateProcess.ProcessSetup(DefaultProcessand newProcess, XmlDocument InputData, XmlDocument xmlProcess, String ProcessName, String ProjectName, String UserName)
at SourceCode.WebDesigner.Authoring.Forms.GenerateProcess.Generate(String LocalHostConnection, String UserName, Int32 ProcessID, String InputData, String ProcessXML, String SqlConnectionString, String HostServerConnectionString)
Issue _ 2:
When starting a workflow (submit Smartform on SharePoint) via a SP group, it says the AAD user does not have permission to start. The user is the Site Collection Administrator and is also a member of the Site Owner which is specified as having start permission in the K2 process. It does work if I specifically add that AAD user to the Process permission.
Resolution
Issue _ 1:
The error message usually indicates that the default environment library for deployment has not been set. You can check this by going to K2 Workspace-> Management(Management Console)-> tServerName]->Environment Library > Templates > Default Template > Environments.
Once you've determined the default environment library template, run through the steps outlined below:
- Navigate and locate the web.cofig file in the "eInstallDir]K2 blackpearlK2 smartforms DesignerWorkflow" folder directory
- Take a backup of this file.
- Now, edit this file using notepad or any other text editing tool of your choice locate the '' element, and change the "value" to the name of your default Environment as determined above.
- Perform an IIS reset.
- Restart the K2 blackpearl service.
Issue _ 2:
The issue was related to K2 not caching the SP Group correctly. Executing the "Get Group Users" method from UMUser SmartObject cached the SP group and the SP Group member was then able to trigger the workflow successfully.