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

Forums / General Discussions / save page (without workflow)

save page (without workflow)

5 posts, 0 answered
  1. Meister
    Meister avatar
    262 posts
    Registered:
    09 Nov 2007
    06 Oct 2009
    Link to this post
    Is it possible to save a page without using workflow
    if not, is it possible to cut down the workflow stages to save and publish?
  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    06 Oct 2009
    Link to this post
    Hi Quade,

    Thank you for using our services.

    What you are asking for cannot be done without workflow. However you can customize the built in workflow to go straight to publish. You can do this by inheriting form the available page workflow class and just shortening the activities. Consider example bellow:
    using Telerik.Cms;  
    using Telerik.Workflow;  
      
    /// <summary>  
    /// Summary description for CustomPageWorkflow  
    /// </summary>  
    public class CustomPageWorkflow : PageWorkflow  
    {  
        protected override void LoadActivities()  
        {  
          
            ListenActivity listen = Activity.Load<ListenActivity>(base.Transaction);  
            base.AddActivity(listen);  
      
            EventActivity eventActivity = Activity.Load<EventActivity>(base.Transaction); 
            eventActivity.Caption = "Publish"
            eventActivity.CommandName = "Publish"
            listen.AddActivity(eventActivity);  
     
            SetApprovalStatusActivity setStatus = Activity.Load<SetApprovalStatusActivity>(base.Transaction);  
             
            ConditionActivity trueActivity = Activity.Load<ConditionActivity>(base.Transaction);  
            trueActivity.Condition = true;  
         
            listen = Activity.Load<ListenActivity>(base.Transaction); 
            trueActivity.AddActivity(listen);  
      
            eventActivity = Activity.Load<EventActivity>(base.Transaction);  
            eventActivity.Caption = "Publish";  
            eventActivity.CommandName = "Publish";  
            listen.AddActivity(eventActivity);  
      
            CallExternalMethodActivity callMethod = Activity.Load<CallExternalMethodActivity>(base.Transaction);  
            callMethod.InterfaceType = typeof(CmsWorkflowService);  
            callMethod.MethodName = "PublishPage";  
            callMethod.Parameters = new object[] { base.ItemId };  
            eventActivity.AddActivity(callMethod);  
      
            setStatus = Activity.Load<SetApprovalStatusActivity>(base.Transaction);  
            setStatus.ApprovalStatus = ApprovalStatus.Published;  
            eventActivity.AddActivity(setStatus);  
        }  
    }  

    After you have added this as a new class in your App_Code directory, modify the web.config so it uses your workflow:
    <add connectionStringName="DefaultConnection" allowPageHistory="true" allowPageWorkflow="true" pageWorkflowType="CustomPageWorkflow" cachingProviderName="ASPNET" name="Sitefinity" type="Telerik.Cms.Data.DefaultProvider, Telerik.Cms.Data"/> 
     


    More information on the relevant topic can be found in this forum thread and blog post.

    Sincerely yours,
    Radoslav Georgiev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Elizabeth
    Elizabeth avatar
    83 posts
    Registered:
    23 Mar 2005
    02 Nov 2009
    Link to this post
    I'm looking at this forum thread and this one, to customize the workflow so that approving an item will publish it. Our current CMS system has a one step approval/publish system and I'm trying to minimize the clicks.

    I have that part working, but what I'd really like to do is that when an approver is editing the page, they just have save and approve and don't have to click on "send for approval".

    How can I customize the workflow based on user roles?
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    03 Nov 2009
    Link to this post
    Hi Elizabeth,

    Below is a sample code that skips the Workflow statuses depending on the currently logged in user.

    void button1_Click(object sender, EventArgs e)
      {
     
            // GET THE PAGE
            ICmsPage pageForEdit = (ICmsPage)cmsManager.GetPage(new Guid("8A56164C-4A6B-453E-9D9B-50AEABD2B409"));
            WorkflowInstance workflow = pageForEdit.GetWorkflow();
            PageWorkflow activity = (PageWorkflow)workflow.Activity;
            if (activity.ApprovalStatus != ApprovalStatus.Published && UserManager.IsCurrentUserInRole("Administrators"))
            {
                  // SEND THIS PAGE DIRECTLY FOR APPROVAL - SKIPPING THE APPROVAL STATUSES
                // FROM THE USER INTERFACE
                ICmsPage stagedPage = (ICmsPage)cmsManager.GetPage(pageForEdit.ID, true);
                ExecuteActivity(stagedPage.WorkflowID, "SendForApproval");
                Nolics.ORMapper.Base.DataConnection.InitWebRequest();
                ExecuteActivity(stagedPage.WorkflowID, "Approve");
                Nolics.ORMapper.Base.DataConnection.InitWebRequest();
                cmsManager.SavePage(stagedPage);
        }
             
      //HELPER METHODS
     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)
            {
                PageWorkflow workflow = (PageWorkflow)instance.Activity;
                EventActivity activity = FindActivity(activityName, workflow.Activities);
                if (activity != null)
                {
                    activity.Execute(WorkflowRuntime.Instance);
                }
     
            }
     
        }

    You can extend the code if necessary.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  5. Sandeep Gupta
    Sandeep Gupta avatar
    5 posts
    Registered:
    17 Apr 2009
    04 Oct 2012
    Link to this post
    Hi Radoslav Georgie,

    I have tried to customize work flow using mentioned class file "CustomPageWorkflow " but failed
    to publish pages. Can you please help me to sort out from this issue. I have tried to publish page after clicking "Publish" button but changes are not reflecting after publishing.
    Please help me ASAP..

    Thanks,
    Sandeep Gupta
    from IDS Logic Pvt ltd
Register for webinar
5 posts, 0 answered