Symptoms
Error: The workflowSetting gWorkflowName] could not be found. Ensure that your workflow is deployed before packaging.
The workflow in the error messasge had been previously deleted but the workflow settings entry still remain in the tK2].KIntegration].oProcessSharePointWorkflow] table.
Diagnoses
This is known issue which has been adressed in 4.7 release (internal ID 574160) - "P&D WEBUI - Cannot create Package after deleting a workflow from SP and after deleting version and log details from Workspace"
Workaround here is deletion of orphan entries from K2 DB, specifically from Integration.ProcessSharePointWorkflow and sometimes from Integration.ProcessSharePointSetting table.
You may use the following SQL scripts to check for presence of orphan records in these tables:
--QUERY A
USE K2 SELECT *
FROM sIntegration].ProcessSharePointWorkflow
WHERE WorkflowName = 'Name_of_workflow_from_error_message_1'
OR WorkflowName = 'Name_of_workflow_from_error_message_2'
OR WorkflowName = 'Name_of_workflow_from_error_message_N'
--QUERY B
SELECT *
FROM >Integration].ProcessSharePointSetting
WHERE ID = '%GUID%' --USE ID VALUES FROM OUTPUT OF THE SCRIPT ABOVE
Resolution
Deleting the workflow settings entry for the workflow in error from the fIntegration].oProcessSharePointWorkflow] table in the database resolves this issue.
Contact K2 Support for assistance and guidance on removing orphan entries from K2 DB.