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

Forums / Developing with Sitefinity / How to programmatically send a blog post for approval

How to programmatically send a blog post for approval

3 posts, 0 answered
  1. S. Webb
    S. Webb avatar
    36 posts
    Registered:
    28 Dec 2006
    22 Sep 2010
    Link to this post
    Hi,

    We have a custom application we are working on that creates blog posts. I have enabled the workflow for blog posts and it works great. In Sitefinity if I create a blog post it creates it as a draft and then the user has to manually click the "Send for Approval" button. This works great but what I want is for my custom application that integrates with Sitefinity to be able to create a blog post and automatically put it in the state where the "Approve" and "Decline" buttons appear.

    How do I get it from status "Draft" to status "ForApproval" programmatically?

    Thanks,
  2. S. Webb
    S. Webb avatar
    36 posts
    Registered:
    28 Dec 2006
    22 Sep 2010
    Link to this post
    I've found the solution for this and I will post it shortly for anyone else who wants to know.

    Thanks,
  3. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    22 Sep 2010
    Link to this post
    Hello Steve,

    Here is a sample code that illustrate how to do this.

    var manager = new ContentManager("Blogs");
               var itemID = new Guid(e.CommandArgument.ToString());
               var itemToChange = manager.GetCurrentState(itemID);
               WorkflowInstance workflow = WorkflowRuntime.Instance.GetWorkflow(itemToChange.WorkflowInstanceId);
               ContentWorkflow activity = (ContentWorkflow)workflow.Activity;
               if (activity.ApprovalStatus == ApprovalStatus.Approved)
               {
                   ExecuteActivity(itemToChange.WorkflowInstanceId, "Publish");
                   Nolics.ORMapper.Base.DataConnection.InitWebRequest();
               }

    There is an old blog post that you can check Schedule content items publishing with workflow enabled

    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Register for webinar
3 posts, 0 answered