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

Forums / General Discussions / Notify roles for content approval and publishing for blog posts

Notify roles for content approval and publishing for blog posts

14 posts, 0 answered
  1. vipul patel
    vipul patel avatar
    37 posts
    Registered:
    12 Mar 2010
    21 Jun 2010
    Link to this post
    Hi,

    I am new Sitefinity, currently working for a blogs website,  We have a requirement to notify roles that content has been sent for approval or publishing for the blog posts,  I have read d knowledge base article located at:
    http://www.sitefinity.com/devnet/kb/sitefinity-3-x/how-to-notify-roles-that-content-has-been-sent-for-approval.aspx
    which is for the news module,  i have made the changes mentioned at the bottom of the article to make it work for the blogs but it is throwing many errors,  i think the code for the control template is not complete,  can some one help me how to achieve this.

    Thanks,
    Vipul Patel
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    21 Jun 2010
    Link to this post
    Hi vipul patel,

    The logic and the steps are the same. The difference is that you should map PostPreview.ascx external template and use PostPreviewView instead of NewsItemPreview to make a reference the the content item.

    Best wishes,
    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
  3. vipul patel
    vipul patel avatar
    37 posts
    Registered:
    12 Mar 2010
    21 Jun 2010
    Link to this post
    Hi Ivan,

    Thanks for your quick reply,

    I think the code pasted on this page seems missing the end part, can you send me the full code ?


    Thanks,

    Vipul Patel
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    21 Jun 2010
    Link to this post
    Hello vipul patel,

    Here is a sample

    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")))
            {
                 
              .....
                      .......
                
     
                switch (commands[idx].CommandName)
                {
                    case "SendForApproval":
                        
                        break;
                    case "Approve":
                   
                        break;
                    case "Decline":
                      
                        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);
        }
    }
     
     
    private string GetApproverGroup(string URL)
    {
        string strGroupName = "";
        string[] strArray = URL.Split('/');
        switch (strArray[1].ToString().ToLower())
        {
            case "case1":
            case "case1.aspx":
                strGroupName = "case1-approvers";
                break;
            case "case2":
            case "case2.aspx":
                strGroupName = "case2-approvers";
                break;
            default:
                strGroupName = "case3-approvers";
                break;
        }
     
        return strGroupName;
    }


    Kind regards,
    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
  5. vipul patel
    vipul patel avatar
    37 posts
    Registered:
    12 Mar 2010
    21 Jun 2010
    Link to this post
    Thanks Ivan,

    I will try now and let you know if i have any issues.

    Thanks,

    Vipul Patel
  6. vipul patel
    vipul patel avatar
    37 posts
    Registered:
    12 Mar 2010
    21 Jun 2010
    Link to this post
    Hi Ivan,

    My code for email notification is working well now, however i am have a problem that when i sign in as blog editor and create a blog post, once i send the blog post for approval it gets locked by the same user untill the user goes to edit the blog post and then cancel.  Can you help me here as the publisher cannot publish or approve the blog post untill that lock on the blog post is removed, please let me know where am i going wrong.

    Thanks,

    Vipul Patel
  7. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    22 Jun 2010
    Link to this post
    Hello vipul patel,

    Somewhere in your code you are using GetContent or another method of of the ConentManager which locks the item. Try using manager.GetCurrentState which should not change the content status and the content item should remain unchanged during the workflow stages.

    Sincerely yours,
    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
  8. vipul patel
    vipul patel avatar
    37 posts
    Registered:
    12 Mar 2010
    22 Jun 2010
    Link to this post
    Hi Ivan,

    Thanks for your reply, I am using the below code to test SendforApproval event:
    I cannot find the ContentManager in my code, Can you let me know where am i going wrong?

    void workflowMenu_Command(object sender, CommandEventArgs e)
       {
           WorkflowInstance workflow = ((WorkflowMenu)sender).GetWorkflow();
           if (workflow != null)
           {
               List<EventActivity> commands = new List<EventActivity>();
               this.LoadCommands(commands, workflow.Activity.Activities);
               int idx = int.Parse((string)e.CommandArgument);
               // The workflow events you could handle are: SendForApproval, Approve, Decline, Publish  
               if ((commands.Count > idx) && (commands[idx].CommandName.Equals("SendForApproval")))
               {
                   // Getting currently modified content and format the message  
                   PostPreviewView itemPreview = (PostPreviewView)this.Parent.Parent;
                   Guid contentID = new Guid(CmsHttpRequest.Current.QueryStirng[itemPreview.ParameterKey]);
                   IContent content = itemPreview.Manager.GetStagedContent(contentID);
                   string url = itemPreview.CreateHostViewCommand<PostPreviewView>(contentID.ToString());   
                   MailMessage mailMsg = new MailMessage();
                   // From   
                   MailAddress mailAddress = new MailAddress("vipul.patel@lg-legal.com");
                   mailMsg.From = mailAddress;
                   // Subject and Body   
                   mailMsg.Subject = "Blog posts item pending approval";
                   //mailMsg.Body = message;
                   //mailMsg.Body = "this is a test role workflow email notification";
                   mailMsg.Body = String.Format("'{0}' blog post item has been sent for approval\n\nhttp://{2}{3}", content.GetMetaData("Title"), content.ID, Request.Url.Host, url);  
                   // To  
                   string approversRole = "Blog Approver";
                   string[] usernames = Telerik.Security.UserManager.Default.GetUsersInRole(approversRole);
                   //if (usernames.Length == 0)
                   //    usernames = Telerik.Security.UserManager.Default.GetUsersInRole("administrators");   
                   foreach (string username in usernames)
                   {
                       System.Web.Security.MembershipUser user = Telerik.Security.UserManager.Default.GetUser(username);
                       mailMsg.To.Add(user.Email);
                   }
                   // Init SmtpClient and send   
                   SmtpClient smtpClient = new SmtpClient();
                   smtpClient.Send(mailMsg);
               }
           }   
             
       }
  9. vipul patel
    vipul patel avatar
    37 posts
    Registered:
    12 Mar 2010
    22 Jun 2010
    Link to this post
    Hi Ivan,

    Can you help me with my above problem?

    Thanks,

    Vipul Patel
  10. vipul patel
    vipul patel avatar
    37 posts
    Registered:
    12 Mar 2010
    22 Jun 2010
    Link to this post
    Hi Ivan,

    I am using the same code supplied by you for the email notification, can you help me in resolving the problem?

    Thanks,

    Vipul
  11. vipul patel
    vipul patel avatar
    37 posts
    Registered:
    12 Mar 2010
    23 Jun 2010
    Link to this post
    Hi Ivan,

    Can you reply and help me to solve my lock problem as mentioned above? I am still stuck with it as we are in the last stage and want to launch our live sitefinity website before the end of this month.

    Thanks,

    Vipul Patel
  12. martin
    martin avatar
    25 posts
    Registered:
    05 Sep 2008
    18 Jan 2011
    Link to this post
    Hi did you ever resolve this issue as I'm experiencing the same issue now?
    Thanks
    Martin.
  13. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    18 Jan 2011
    Link to this post
    Hi,

    The lock issue is resolved when you use GetCurrentState Method


    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
  14. martin
    martin avatar
    25 posts
    Registered:
    05 Sep 2008
    18 Jan 2011
    Link to this post
    Sorted. Thanks.
Register for webinar
14 posts, 0 answered