Try our conversational search powered by Generative AI!

Loading...
Area: Optimizely CMS
ARCHIVED This content is retired and no longer maintained. See the latest version here.

Recommended reading 

Introduction

This document provides an introduction to the messaging functionality in EPiServer. There are many scenarios where it is useful for an editor to be made aware of the current working page status. One example is when a specific page property is edited or when a page is submitted for editing. A common solution for providing this kind of action result notifications to editors is therefore available in the EPiServer platform.

The message service store uses a central message pool. The solution contains two main parts:

  • A central message hub service which can support other parts in adding or removing items.
  • A widget container displaying all the notification items for a current working page to a user.

Adding message service component

The message service is the central hub which is registered in the EPiServer Framework ShellModule.

Whenever you want to refer to the message service you just use a dependency to resolve it.


this._messagePool = epi.dependency.resolve("epi.shell.MessageService");

Methods


put: function ( /*String*/typeName,
                /*String*/message,
                /*String*/contextTypeName,
                /*Object*/contextId,
                /*Object*/externalItemId,
                /*Object*/externalItemData) 

remove: function (/*Object?*/query)

query: function (/*Object?*/query)

observe: function (/*Object?*/query, callback)
            

Examples

The example code below shows how to to add a page property item error to the global message queue.


this._messagePool.put("error", result.error, "Page", this.pageLink, item.propertyName, item.item);

The example code below shows how to remove a page property item error from the global message queue.


this._messagePool.remove({
    contextTypeName: "Page",
    contextId: this.pageLink,
    externalItemId: item.propertyName,
    externalItemData: item.item });

The example code below shows how to query error items with a specific [contextTypeName] and [contextId] in the global message queue.


this._query = { typeName: "error", contextTypeName: this.contextTypeName, contextId: this.contextId};
var messages = this._messagePool.query(this._query);

The example code below shows how to observe a message with a specific [contextTypeName] and [contextId] in the global message queue, with query conditions.


this._messagePool.observe({ contextTypeName: messageContext.contextTypeName, contextId: messageContext.contextId });

Message service listener widget

Currently the [NotificationStatusBar] widget is just injected to the status bar and will observe all changes in the message queue related to the current working page. The widget will then display all message elements for the current working page, for example errors, warnings and notifications.

Do you find this information helpful? Please log in to provide feedback.

Last updated: Feb 23, 2015

Recommended reading