Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set the next activity from the current automated activity?

I am trying to decide the next activity from the current activity (Automatic decision activity)The below is my code. How to set the next activity?

public void DebugUserCheck(string workitemid)
{
  CoreServiceSession client = new CoreServiceSession();
  SessionAwareCoreServiceClient csClient = client.GetClient();
  var readoption = new ReadOptions();
  WorkItemData workitem = (WorkItemData)csClient.Read(workitemid, readoption);          


  ActivityInstanceData currentactivity = (ActivityInstanceData)csClient.Read(workitem.Activity.IdRef, readoption);
  TridionActivityDefinitionData activitydefinition = (TridionActivityDefinitionData)csClient.Read(currentactivity.ActivityDefinition.IdRef, readoption);
  ProcessDefinitionData processdefinition = (ProcessDefinitionData)csClient.Read(activitydefinition.ProcessDefinition.IdRef, readoption);
  IList<ActivityDefinitionData> activityDefinitions = new List<ActivityDefinitionData>(processdefinition.ActivityDefinitions);

  string superuseractivitytitle = "";
  string superuseractivityid = "";
  string normaluseractivitytitle = "";
  string normaluseractivityid = "";

  foreach (var activity in activityDefinitions)
  {
    if (activity.Title == "Override")
    {
      superuseractivitytitle = activity.Title;
      superuseractivityid = activity.Id;                    
    }
    if (activity.Title == "Author Decision")
    {
      normaluseractivitytitle = activity.Title;
      normaluseractivityid = activity.Id;
    }
  }


  UserData user = csClient.GetCurrentUser();

  if (user.Id == "tcm:0-141-65552")
  {
    ActivityDefinitionData nextactivity = (ActivityDefinitionData)csClient.Read(superuseractivityid, readoption);
    ActivityFinishData finishdata = new ActivityFinishData();
    finishdata.Message = "Automatic decision activity finished";
    csClient.FinishActivity(currentactivity.Id, finishdata, readoption);
  }
  else
  {
    ActivityDefinitionData nextactivity = (ActivityDefinitionData)csClient.Read(normaluseractivityid, readoption);
    ActivityFinishData finishdata = new ActivityFinishData();
    finishdata.Message = "Automatic decision activity finished";
    csClient.FinishActivity(currentactivity.Id, finishdata, readoption);
  }            

}   
like image 499
user1428019 Avatar asked Jul 18 '12 09:07

user1428019


People also ask

How can you start another activity from the current activity?

To start an activity, use the method startActivity(intent) . This method is defined on the Context object which Activity extends. The following code demonstrates how you can start another activity via an intent. # Start the activity connect to the # specified class Intent i = new Intent(this, ActivityTwo.

How do I go back to previous activity on Android?

Android activities are stored in the activity stack. Going back to a previous activity could mean two things. You opened the new activity from another activity with startActivityForResult. In that case you can just call the finishActivity() function from your code and it'll take you back to the previous activity.


1 Answers

Instead of ActivityFinishData use DecisionActivityFinishData

var decisionActivityFinishData = new DecisionActivityFinishData
{
  NextActivity = new LinkToActivityDefinitionData{IdRef = "next activity ID"}
};
csClient.FinishActivity(currentactivity.Id, decisionActivityFinishData, 
                        readoption);
like image 166
Andrey Marchuk Avatar answered Sep 20 '22 13:09

Andrey Marchuk