0

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());
    }
  }
}
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Jey
  • 2,137
  • 4
  • 22
  • 40

1 Answers1

1

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.

Nuno Linhares
  • 10,214
  • 1
  • 22
  • 42
  • what are the flows in workflows ? say for ex: if you ask me to create page using API, i can say like 1. get sg object, 2. create new page object 3. set file name, 4. set pt, 5. add cp 6. save. like this what are the flows/steps i have to follow in workflow, i dont see any docs related this and more over am new to coreservice, this is not like tom.net or tom. – Jey Jul 06 '12 at 12:55
  • Look at the code you had before http://stackoverflow.com/questions/11339510/automatic-activity-not-performing - get a session, get the current WorkItem, the current Activity, finish the current activity. The flow does not change just because you changed API – Nuno Linhares Jul 06 '12 at 13:41