Labels

Friday, September 28, 2012

Simple notification service

In Microsoft Dynamics NAV 2009 platform new triggers OnDatabaseInsert, OnDatabaseModify, OnDatabaseDelete, OnDatabaseRename were added. They are fired even in code you don't call triggers  INSERT, MODIFY, DELETE with TRUE arguement. In standard functionality these triggers are used for integration with Microsoft Dynamics CRM product.
The Business Notification Server functionality is too complex and requires some additional granules, that costs some money. So, I 've created the alternative lightweight universal solution for notification. IT manager has the possibility to subscribe user for special events on any table. And user will get notification in his mailbox.

Log of this events is accumulated in the own Notification Entry table. In my conditions Navision Application Server was absent and I could not use standard scheduler functionality for sending notifications. The idea was to use Windows scheduler instead. I've publicated the Codeunit for notification through Web-service and invoke it with additional .NET assembly and have setted scheduler to run it once per 5 minutes.
There was also feature to notify user with nice HTML message, containing the values of all fields in the record. For that case I've realized the importing XSL template of the message and transforming data in record with it.
I've faced the problem of sending the result message through SMTP codeunit, because it should contain cyrillic letters. The solution was that XSLT file should be in CP866 (MS DOS) codepage, and it should be setted also for output, here is the beggining of that file:

<?xml version="1.0" encoding="cp866"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="cp866"/>
<xsl:template match="/">
<html>

No comments: