Sitefinity Toolkit: Workflow Notifications

By in
No comments

Apologies for the delay in continuing this series. Life keeps me busy, and while I wouldn’t have it any other way, it’s sometimes difficult to find time for the little things. I’d also like to thank Darren L for providing the first donation to my studio fund! Because of his kind feedback and donation, I’ll be releasing an update to the Sitefinity Password Recovery that will fix a few issues he encountered. Stay tuned for that, and please feel free to kick in a donation of your own (see sidebar for details).

Overview

NOTE: This feature is ONLY available for the STANDARD version of Sitefinity (not the community edition). Only the standard version includes the workflow feature, and as a result, this feature will not work with the community edition..

Sitefinity has a nice, if somewhat basic, workflow system that allows vetting of new content. Although I have to admit that I am looking forward to some big improvements to this in future versions, for the most part it works well. However, one key feature missing out-of-the-box is automatic notifications of changes to content item status.

I’ve attempted to address this by adding email notifications to content items for the News, Events, and Generic Content Modules. Implementation is VERY BASIC at this point, but it was enough to fit my current needs. As with all the other features of this project, I hope to build on it through future releases.

Installation

As always first download the sitefinity toolkit and unzip to your site’s bin directory.

You also need to setup your email credentials in the system.net node of your web.config file:

 <system.net>
    <mailSettings>
        <smtp>
             <network host="SERVERNAME" userName="USERNAME" password="PASSWORD" /> 
        </smtp>
     </mailSettings>
</system.net>

Finally, you need to make sure to enable workflow is enabled for each module:

<add name="Generic_Content" ... allowWorkflow="True" ... type="Telerik.Cms.Engine.Data.Providers.DefaultProvider, Telerik.Cms.Engine.Data" />
<add name="Events" ... allowWorkflow="True" ... type="Telerik.Events.Data.DefaultEventsProvider, Telerik.Events.Data" />
<add name="News" ... allowWorkflow="True" ... type="Telerik.News.Data.DefaultNewsProvider, Telerik.News.Data" />

Required Roles

In order for this feature to work, you need to define the following Roles (you can create these in the Sitefinity Administration tab) and add at least one user to each role. As the role names imply, these are the people who will be approving and publishing the items as they are submitted.

  • Approvers
  • Publishers

In addition to the above roles, you must create roles whose names match the names of the default providers for each module. On my site, the default provider for Generic Content is Software, so to use all three notifications, I would create the following roles:

  • News
  • Events
  • Software

Then I would assign to each role the users responsible, and set appropriate permissions for each module. Be sure that the Approvers and Publishers from the roles you created above are also members of the Module roles or the notifications will not be sent!

External Templates

Now you need to map external templates for your module’s administration. Be sure that your external templates use a full User Control that includes the associated code-behind page. The following templates need to be mapped:

  • NewsItemPreview
  • EventsItemPreview
  • ContentPreview (For Generic Content Module)

All you have to do now is modify the base class for each external template so that instead of inheriting from UserControl, they inherit from the corresponding template class in the toolkit:

News

public partial class Templates_Admin_News_NewsItemPreview : SelArom.Net.Sitefinity.Templates.NewsItemPreview{

}

Events

public partial class Templates_Admin_Events_EventsItemPreview : SelArom.Net.Sitefinity.Templates.EventsItemPreview{

}

Generic Content

public partial class Templates_Admin_Generic_Content_ContentPreview : SelArom.Net.Sitefinity.Templates.ContentPreview{

}

Usage

Once you have everything above setup, the notifications should automatically execute whenever workflow status is enabled. The email simply includes a notification and a link to the appropriate module. No item data is included; I hope to add that in a future release.

One thing I was careful to include is if a user is in the role they are submitting (for example, a user submitting for approval is also in the approvers role), then an email is not sent.

My needs for this feature were very limited and specific, so I’ll admit I have not done extensive testing on it. I do know it will crash if the above roles do not exist, so be sure if you want to use this feature that you follow the instructions carefully! I hope to refine this feature greatly in future releases, so if find I’ve left something out, or if you have any feedback or suggestions, please email me and if you use and enjoy my work, please consider following Darren’s lead and kicking a small donation to expand my music studio!

The following two tabs change content below.

selaromdotnet

Senior Developer at iD Tech
Josh loves all things Microsoft and Windows, and develops solutions for Web, Desktop and Mobile using the .NET Framework, Azure, UWP and everything else in the Microsoft Stack. His other passion is music, and in his spare time Josh spins and produces electronic music under the name DJ SelArom. His other passion is music, and in his spare time Josh spins and produces electronic music under the name DJ SelArom.