More in this section

Forums / Developing with Sitefinity / Debugger not hitting custom notification class consistently

Debugger not hitting custom notification class consistently

2 posts, 0 answered
  1. Tom
    Tom avatar
    7 posts
    07 Oct 2013
    12 Jun 2014
    Link to this post


    I have made a new custom class called CustomNotifyGroup to be used instead of the default workflow NotifyGroup class in order to email approval notifications to users with a custom Role. The custom Role to send the notification email to is based on getting the Group Page name that the page being submitted for approval belongs to.


    User sends a page for approval that is under the "Finance" page group. The CustomNotifyGroup.cs code gets that page group named "Finance" and concatenates it with"Editor-" placed before it to make the Role name "Editor-Finance".

    So the users with the Role "Editor-Finance" will then be emailed the notification.

    I replaced NotifyGroup with CustomNotifyGroup in my custom PagesApprovalWorkflow.xamlx file under One Level Approval > Draft item workflow > at the end of the "Send Approval" path.

    In my local environment in Visual Studio I have successfully hit the class code using the debugger before. Many times though it simply will not hit the code when I hit "Send for Approval" on a page. I do not know the reason for this inconsistency (I am sure the debugger is always running when I test this).

    Any thoughts to why this class code is only sometimes hit in the debugger through the workflow?

    Do you have a link to how to debug by placing a breakpoint inside the workflow XALMX file itself?


    using System;
    using System.Activities;
    using System.Collections.Generic;
    using System.Drawing.Text;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using Telerik.Sitefinity;
    using Telerik.Sitefinity.Fluent.AnyContent.Implementation;
    using Telerik.Sitefinity.Security;
    using Telerik.Sitefinity.Security.Model;
    using Telerik.Sitefinity.Services;
    using Telerik.Sitefinity.Services.Notifications;
    using Telerik.Sitefinity.Versioning.Comparison;
    using Telerik.Sitefinity.Workflow.Activities;
    using Telerik.Sitefinity.Workflow.Model;
    using Telerik.Sitefinity.Pages.Model;

    namespace Ucsb.Aa.GradDiv.Web.Workflows
        public class CustomNotifyGroup : NotifyGroup
            List<string> emailList = new List<string>();
            string messageBody = null;

            protected override void Execute(CodeActivityContext context)
                    var dataContext = context.DataContext;
                    var workflowDefinition = (WorkflowDefinition)dataContext.GetProperties()["workflowDefinition"].GetValue(dataContext);
                    if (workflowDefinition != null)
                        if (workflowDefinition.WorkflowType == WorkflowType.StandardOneStep && !workflowDefinition.SendFirstLevelEmailNotification)


                        if (workflowDefinition.WorkflowType == WorkflowType.StandardTwoStep)
                            var approvalState = (((AnyDraftFacade)(dataContext.GetProperties()["masterFluent"].GetValue(dataContext))).Get() as IApprovalWorkflowItem).ApprovalWorkflowState;

                            if (approvalState == "AwaitingPublishing" && !workflowDefinition.SendSecondLevelEmailNotification)

                            if (approvalState == "AwaitingApproval" && !workflowDefinition.SendFirstLevelEmailNotification)

                    //uses the notification service to send a message
                catch (Exception ex)
                { }

            public void SendMessage()
                var serviceContext = new Telerik.Sitefinity.Services.Notifications.ServiceContext(null, null);
                var messageTemplate = new Telerik.Sitefinity.Services.Notifications.MessageTemplateRequestProxy() { Subject = "Subject", BodyHtml = messageBody };
                var messageJob = new Telerik.Sitefinity.Services.Notifications.MessageJobRequestProxy()
                    Description = "Sending message through workflow",
                    MessageTemplate = messageTemplate,
                    Subscribers = new List<SubscriberRequestProxy>()
                                new SubscriberRequestProxy()
                                    Email = emailList[0],
                                    ResolveKey = Guid.NewGuid().ToString()
                SystemManager.GetNotificationService().SendMessage(serviceContext, messageJob, null);

            private List<string> GetEditorEmailListByPageGroup(CodeActivityContext context)
                string pageGroupName = GetPageGroupName(context);

                List<User> users = GetUsersInRole("Editor-" + pageGroupName);
                List<string> editorEmailList = new List<string>();

                foreach (var user in users)
                    if (!user.Email.IsNullOrEmpty())
                return editorEmailList;

            private string GetPageGroupName(CodeActivityContext context)
                var property = context.DataContext.GetProperties()["workflowItem"];
                if (property != null)
                    var securedItem = property.GetValue(context.DataContext);
                    var pageNode = securedItem as Telerik.Sitefinity.Pages.Model.PageNode;
                    string groupName = null;
                    while (pageNode.Parent != null)
                        var parent = pageNode.Parent;
                        if (parent.NodeType == Telerik.Sitefinity.Pages.Model.NodeType.Group)
                        // you can add a check if it is one of your top groups
                            groupName = parent.Title;
                        pageNode = pageNode.Parent;

                    if (string.IsNullOrEmpty(groupName)) return String.Empty;
                    return groupName;
                return String.Empty;


  2. Svetoslav Manchev
    Svetoslav Manchev avatar
    735 posts
    06 Sep 2017
    17 Jun 2014
    Link to this post
    Hi Tom,

    Please check the setting of the custom workflow if it is the same as on your local machine where it works fine. You could check also the example in the documentation about the custom workflow notifications it everything is set properly.

    You can check the the error logs? To do so:
    - Remove all the files under ~\<your project>\App_Data\Sitefinity\Logs\...
    - Reproduce the case
    - Check the file/s generated in the above mentioned folder for any related error that could refer to the problem, why your code is not executed.

    Svetoslav Manchev
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
2 posts, 0 answered