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

Forums / Developing with Sitefinity / Workflow question

Workflow question

5 posts, 0 answered
  1. jcrichto
    jcrichto avatar
    35 posts
    Registered:
    14 Aug 2012
    03 Feb 2009
    Link to this post
    I am dynamically building nav based on workflow.  I check the state like so.

    <code>
    if (activity.ApprovalStatus == ApprovalStatus.Published) showInNav=true;
    </code>

    However, if a new Draft is created for this page, approvalstatus changes, and the nav will disappear. 

    Is there a way that I could for a previously published page, and thus allow the link in the nav in this case as well?

    Thanks,

    Jeremy
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    04 Feb 2009
    Link to this post
    Hello Jeremy,

    Please take a look at the sample below:

           // change show in navigation depending on the workflow status 
            pageForEdit = (ICmsPage)cmsManager.GetPage(nodeForEdit.CmsPage.ID, true); 
            WorkflowInstance workflow = pageForEdit.GetWorkflow(); 
            PageWorkflow activity = (PageWorkflow)workflow.Activity; 
     
            if(activity.ApprovalStatus == ApprovalStatus.ForApproval) 
            {  
                pageForEdit.Navigable = true
            } 
        } 

    I hope this helps.

    Regards,
    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. jcrichto
    jcrichto avatar
    35 posts
    Registered:
    14 Aug 2012
    04 Feb 2009
    Link to this post
    Hello Ivan,

    Actually I am already doing pretty much what you are showing.  here is my code. (BTW, how do I format code on this forum like you did? Taking a guess each time I post)

    [code]
            WorkflowInstance workflow;
        workflow = node.GetWorkflow();
        if (workflow != null)
        {
            PageWorkflow activity = (PageWorkflow)workflow.Activity;
            if ((isSitefinity &&
                    (activity.ApprovalStatus == ApprovalStatus.Draft || activity.ApprovalStatus == ApprovalStatus.ForApproval || activity.ApprovalStatus == ApprovalStatus.Approved))
                || activity.ApprovalStatus == ApprovalStatus.Published)
            {
                allowNav = true;
            }
        }
        else 
        {
            allowNav = true;
        }
    [/code]

    However my problem isn't in how to check workflow, but  how to check to see if there is a previously published version of the page available.  You see, I am allowing Unplublished and Unapproved pages to appear in the nav inside /sitefinity/ "isSitefinity" but not on the main site.  

    This works great until a page goes from Published, back to Draft again.  I need to be able to look at the history of the page to find out if it has a previously published version . If I know this, I will allow the nav to stay in place in the main site.

    Thanks,

    Jeremy
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    04 Feb 2009
    Link to this post
    Hello Jeremy,

    Here I am creating a bool variable published, and then check whether the page has been published. Also, I am including VersionManager to get the current version of the page.

                  VersionManager vm = new VersionManager();      
             bool published = pageForEdit.Status == PageStatus.Published; 
     
            // get the current version of the page 
            int whichVersion = vm.GetVersion(pageForEdit.ID, System.Threading.Thread.CurrentThread.CurrentUICulture); 
     
            // do something 
     
            if(published) 
                // do something 

    It seems that Format Code Block of the editor is disabled so this is the reason why you cannot post the code appropriately. I will talk with our web team if they could take a look at this issue.

    All the best,
    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  5. jcrichto
    jcrichto avatar
    35 posts
    Registered:
    14 Aug 2012
    12 Feb 2009
    Link to this post
    thanks.. this worked perfectly.
Register for webinar
5 posts, 0 answered