More in this section

Forums / Suggestions / By-Pass Workflow

By-Pass Workflow

2 posts, 0 answered
  1. Glenn
    Glenn avatar
    10 posts
    22 Jan 2007
    10 Mar 2009
    Link to this post
    Suggestion: If you are the admin/approver for the site, you should have the ability to bypass the workflow. After you save the page, there should be just a publish button and not an approve. Yeah it's only an extra click but user's like less click's....
  2. Georgi
    Georgi avatar
    3583 posts
    28 Oct 2016
    11 Mar 2009
    Link to this post
    Hello Glenn,

    There are two ways to bypass the workflow, yet we do not have this functionality out of the box.

    First approach:
    You could attach a second project to the same database, and have the workflow disabled in that project. Whoever logs through this project, will skip the entire workflow process when publishing items. Note that the both projects should be using one version of Sitefinity.

    Second approach:
    You can automatically put the content in published state, by iterating through all the steps of the workflow cycle. Let's see how we directly publish a content item, if we have workflow on:
       protected void Page_Load(object sender, EventArgs e)  
            //We are going to create a new News Item  
            NewsManager newsManager = new NewsManager("News");  
            //Then, we have to create new content  
            IContent submittedNews = newsManager.Content.CreateContent("text/html");  
            DateTime mydate = new DateTime();  
            mydate = DateTime.Today;  
            submittedNews.SetMetaData("Publication_Date", mydate );  
            submittedNews.Content = "Here Goes My Content";  
            //Let's save the news item as draft.  
            submittedNews.Status = ContentStatus.Draft;  
            //In order to publish our item, we have to iterate through all   
            //workflow states, until we reach published state  
            StagedContent staged = newsManager.Content.GetCurrentState(submittedNews.ID);  
            //On each step we should clear the Nolics cache...  
            ExecuteActivity(staged.WorkflowInstanceId, "SendForApproval");  
            ExecuteActivity(staged.WorkflowInstanceId, "Approve");  
            ExecuteActivity(staged.WorkflowInstanceId, "Publish");   
        private EventActivity FindActivity(string name, IList<Activity> activities)  
            foreach (Activity act in activities)  
                if ((act is EventActivity) && (((EventActivity)act).CommandName == name))  
                    return (EventActivity)act;  
                EventActivity ea = FindActivity(name, act.Activities);  
                if (ea != null)  
                    return ea;  
            return null;  
        private void ExecuteActivity(Guid id, string activityName)  
            WorkflowInstance instance = WorkflowRuntime.Instance.GetWorkflow(id);  
            if (instance != null)  
                ContentWorkflow workflow = (ContentWorkflow)instance.Activity;  
                EventActivity activity = FindActivity(activityName, workflow.Activities);  
                if (activity != null)  

    Now, we should use this code for any new item, created by specific user (or users from the Administration role). When one creates a content item, the ContentManager.Executing event is raised, giving us a reference to the item and the command executed. We may subscribe to this event, take the item, and push it through the workflow states using the code above. Here is how:
    global.asax file:
        void Application_Start(object sender, EventArgs e) 
            //Event handler for executing the Content Manager 
            Telerik.Cms.Engine.ContentManager.Executing += new EventHandler<Telerik.ExecutingEventArgs>(ContentManager_Executing); 
        void ContentManager_Executing(object sender, Telerik.ExecutingEventArgs e) 
            //Check whether the user is creating content 
            if (e.CommandName == "CreateContent"
                //take the IContent Item from the command arguments 
                Telerik.Cms.Engine.IContent cnt = e.CommandArguments as Telerik.Cms.Engine.IContent; 
                //chech if there is such content and if it belongs to the news provider 
                if (cnt != null && cnt.ProviderName == "News"
                    //get the current user's First and Last names 
                    ProfileBase profile = ProfileBase.Create(HttpContext.Current.User.Identity.Name); 
                    string FirstName = profile.GetPropertyValue("FirstName").ToString(); 
                    if (FirstName.Equals("Admin")) 
                        //Call the code which will push the cnt through the workflow states 

    We subscribed to the ContentManager.Executing event, checked if the user's first name is Admin and should call the code which will push the cnt (also taken from the command arguments) to the desired state.

    I hope this will help you to get your task done.

    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
2 posts, 0 answered