I'm using Tridion 2013 SP1. I'm getting below error while finishing an automatic activity from a decision activity.
Here is my code:
var session = new Session();
WorkItem m_WorkItem = session.GetObject(workitemid) as WorkItem;
ActivityInstance currentactivity = m_WorkItem.Activity as ActivityInstance;
IEnumerable<ActivityDefinition> ieActivities = currentactivity.ActivityDefinition.ProcessDefinition.ActivityDefinitions;
ActivityDefinition activityInstance = ieActivities.ToList().Where(c => c.Title == "Publish EN to Testing and Staging").First();
DecisionActivityFinish finish = new DecisionActivityFinish(activityInstance, session.User, "Publish EN to Testing and Staging", session);
currentactivity.Finish(finish);
Error on the event viewer is like this,
Unable to get activity instance from work item. caused by: WorkItem.ActivityInstance
and description:
<?xml version="1.0"?>
<tcm:Error xmlns:tcm="http://www.tridion.com/ContentManager/5.0" ErrorCode="D" Category="18" Source="Kernel" Severity="1">
<tcm:Line Cause="false" MessageID="16138"><![CDATA[Unable to get ActivityInstance of Workflow work item (tcm:3-125-131200).]]><tcm:Token>RESID_4485</tcm:Token>
<tcm:Token>ActivityInstance</tcm:Token>
<tcm:Token>RESID_15212</tcm:Token>
<tcm:Token>tcm:3-125-131200</tcm:Token>
</tcm:Line>
<tcm:Line ErrorCode="D" Cause="true"><![CDATA[Type mismatch]]></tcm:Line>
<tcm:Details>
<tcm:CallStack>
<tcm:Location>WorkItem.ActivityInstance</tcm:Location>
<tcm:Location>WorkItem.ActivityInstance</tcm:Location>
</tcm:CallStack>
</tcm:Details>
</tcm:Error>