• Sayantan Basu

UI Notification framework

Last week in TDS India I have presented a session on UI Notification framework. Since then I have received few request to share the code, so I think it is best to write a blog on this and share it with everyone.

SDL Web 8.5 has introduced a new feature to send customized UI notification from your custom application. In this blog I am not going to cover the overview and architectural details as it is already described in a blog by Arno.  If you have missed my session or want to learn more about that, then please refer this blog.

Here are few important points which might be useful before you start implementing this feature.

  1. User can send notification from any system using this notification framework.

  2. All client will receive this notification but user can restrict the target group/users from the UI event handler.

  3. Don’t send any sensitive data (Like Content of the component/page) via notification as framework will send this notification to all client.

  4. Only clients those are connected will receive the notification. This notification will not persist if the user is not online.

  5. It is not recommended to create a UI Notification for every event, so only use if there is a strong requirement behind this

Use case:

Suppose customer wants to automate the publishing process for a Page once they click on Save and Close. In this scenario you can notify that user once that page is added in the publishing queue.

Steps:


You can break this requirement into 2 part.

  1. Event Handler

  2. Model/Editor Extension

I have created one solution and added two projects for this.

Event Handler: –

In this stage you have to create an event handler which will publish the page automatically and also broadcast the message to UI.

  1. Write an event Handler. – Decorate your event handler as per the requirement. Here is the code for that.

  2. Add code snippet to broadcast your message. – Include the namespace for Notification

                   using Tridion.ContentManager.Notifications;

– Add below code to broadcast the message to UI. Make sure                     to prefix the Action identifier with something unique for the                    implementation, like :

           <company name>: <notification identifier>

here you can create the data and pass it to UI which might be required to construct  the message. As an example I am passing the the creator Id, Title of the subject and Purpose.

  1. Now your event handler is ready, so you can deploy that. Here are the steps for deployment in case you are doing it for the first time –

– Copy the compiled DLL to the CMS Server under “<TRIDION_HOME>\bin\” – Open the Tridion.ContentManager.config file from “<TRIDION_HOME>\config\” folder

Add the dll to the extensions:

<add assemblyFileName=”<TRIDION_HOME>\bin\Your Event System Code.dll”/>

– Restart COM+ service – Restart the Tridion Services

Create Model/Editor Extension : –

Here I have created model extension. For that you can create a seperate project (As I have created a Model Extension Project here) –

  1. Create a folder (called Scripts) under the project and add Handler Java script. – First you need to check if this is the same message that you have Broadcast yourself from the CM event handler

var description = `Your item ‘${event.data.details.title}’ has been sent for publishing to ‘${event.data.details.purpose}’`;

At the end broadcast that message –


  1. Create a folder (called Configuration) under the project and add Config file. – Configure the resources for that model extension as per requirement. Here is the sample that I have used for this project.

  1. Set up and Register your Model Extension. here are the steps to register the model extension –

– On your Content Manager server machine, access IIS Manager and navigate to the Content Manager Explorer Web site.

– Add a new virtual directory inside the Models subfolder of the Web site root folder, and give it a meaningful name, for example, MyOrgModel.

– Set the physical location of the virtual directory to the location of your custom Model’s resources.

– Access the web\WebUI\WebRoot\Configuration\ subfolder of %TRIDION_HOME%. – Open System.config in that location in a plain-text or XML editor.

– In the <models> section, add a new model element, as follows:

<model name=”MyOrgModel”> <installpath>c:\MyProjects\MyOrgModelResources\</installpath> <configuration>Configuration\MyOrgModel.config</configuration> <vdir>MyOrgModel</vdir></model>

where the value of installpath points to the physical location of your virtual directory, the value of configuration points to the configuration of that Model, relative toinstallpath, and vdir refers to the virtual directory you just created.

– Save and close System.config and restart the Content Manager Explorer Web site.

That’s it. Your notification Framework is ready to use. Now Create a page and Click on Save and Close button  –


You can find the complete source code for this end to end example here.

#Notification #SDLWeb85 #UINotification #EventSystem #NewFeatureofSDLWeb85 #ContentManager

© 2019 by Sayantan Basu