+1-888-365-2779
Try Now
More in this section

Forums / Set-up & Installation / Workflow - Declined Content update

Workflow - Declined Content update

2 posts, 0 answered
  1. Allan Bush
    Allan Bush avatar
    1 posts
    Registered:
    12 Jan 2010
    03 Feb 2010
    Link to this post
    When an approver declines a submitted change, I noticed that the content does not revert to the original state prior to the submitted edit.

    Is there a way to revert the content to the current live version automatically if a submission is declined?
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    03 Feb 2010
    Link to this post
    Hi Allan Bush,

    You need to get the workflow status and from the Workflow activity in ItemPreview template of the module you want to change. Then you have to rollback to the previous version when the content item is declined.

    Steps:

    1. Map the ItemPreview memplate for the module you are going to change.
    2. Create a code behind of the template.
    3. Access the workflow menu and workflow activities.
    4. When the content is declined, perform a rollback.

    sample code:

    protected void Page_Load(object sender, EventArgs e)
    {
             workflowMenu.Command += new CommandEventHandler(workflowMenu_Command);
    }
     
       void workflowMenu_Command(object sender, CommandEventArgs e)
       {
           WorkflowInstance instance = ((WorkflowMenu)sender).GetWorkflow();
           if (instance != null)
           {
               List<EventActivity> commands = new List<EventActivity>();
               this.LoadCommands(commands, instance.Activity.Activities);
               int idx = int.Parse((string)e.CommandArgument);
               if ((commands.Count > idx) && !(commands[idx].CommandName.Equals("Publish")))
               {
                   NewsItemPreview itemPreview = (NewsItemPreview)this.Parent.Parent;
                   Guid contentID = new Guid(CmsHttpRequest.Current.QueryStirng[itemPreview.ParameterKey]);
                   StagedContent content = itemPreview.Manager.GetCurrentState(contentID);
     
                   switch (commands[idx].CommandName)
                   {
                       case "SendForApproval":                                      
                           break;
                       case "Approve":
                           break;
                       case "Decline":
                         // you have the item, just roll back.
                           break;
             
                       case "Publish":
                           break;
                   }
     
               }
           }
       }
     
       private void LoadCommands(List<EventActivity> commands, IList<Activity> activities)
       {
           foreach (Activity act in activities)
           {
               if (act is EventActivity)
                   commands.Add((EventActivity)act);
               this.LoadCommands(commands, act.Activities);
           }
       }


    Regards,
    Ivan Dimitrov
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
2 posts, 0 answered