Skip to content

Commit e5aad9f

Browse files
Update README.md
Added a better explanation of when to use the code
1 parent e5cb79e commit e5aad9f

File tree

1 file changed

+23
-5
lines changed
  • 10/umbraco-cms/reference/notifications

1 file changed

+23
-5
lines changed

10/umbraco-cms/reference/notifications/README.md

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -277,14 +277,32 @@ Umbraco uses notifications to allow people to hook into different workflow proce
277277

278278
## Showing messages in the CMS
279279

280-
You can inform the Umbraco user of the status of your notification by adding messages to the `notification.Messages` property.
280+
When handling notifications for CMS actions, you can inform the Umbraco user of the status of your notification by adding to the `notification.Messages` property within the `Handle` function.
281281

282-
For example:
282+
This could be used to inform the user to an additional operation that has been performed, or alert them to an error that has occoured.
283+
284+
For example, in a `ContentTypeSavedNotification`:
283285

284286
```
285-
notification.Messages.Add(new EventMessage("An Error occoured",
286-
"Detail about the error",
287-
EventMessageType.Error));
287+
public void Handle(TemplateSavedNotification notification)
288+
{
289+
bool success = DoAdditionalCode();
290+
291+
if (success)
292+
{
293+
//on success
294+
notification.Messages.Add(new EventMessage("Save Successful",
295+
"The content was saved successfully",
296+
EventMessageType.Success));
297+
}
298+
else
299+
{
300+
//on error
301+
notification.Messages.Add(new EventMessage("An Error occoured",
302+
"Detail about the error",
303+
EventMessageType.Error));
304+
}
305+
}
288306
```
289307

290308
## Samples

0 commit comments

Comments
 (0)