Search code examples
tridiontridion-2011

Need Startup on workflow using core service


I am creating a first automated activity "back to author" in workflow using coreservice. The below is my code.

  1. created component and finished
  2. reviewed the component and chose "back to author" this is an automated task, for that I have written the below code. But the activity is not performed.

can you please help me on this?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using Tridion.ContentManager.CoreService.Client;

namespace CoreComponentWorkflow
{
  [ProgId("CoreComponentWorkflow.WorkflowHandler")]

  public class AutomaticWorkflowHandler
  {
    public void MoveBackToActivity(string strActivitytoMove)
    {
      var client = new SessionAwareCoreServiceClient();
      var finishdata = new ActivityFinishData();
      finishdata.Message = strActivitytoMove;
      var process = new ProcessInstanceData();
      var activity = (ActivityInstanceData)process.Activities[0];
      client.FinishActivity(activity.Id, finishdata, new ReadOptions());
    }
  }
}

Solution

  • There's a few things in your code that need reviewing.

    1. You create a new ProcessInstanceData instead of reading it from the current instance. Therefore you certainly will not have process.Activities[0] as this process is new.
    2. What parameters are you passing to your activity from the Workflow Script?
    3. Where's your current workItem?

    Review your code with some common sense, and try to follow the flow (with remote debugging for instance). Try comparing with the TOM.NET code you had before, it looks like you are just shooting in the dark here.