Connect Chat and Worknote Notifications

Callum Ridley1
Tera Guru

For some, like myself, worknotes in the system are more useful if they create notifications to ITIL users when tney are added. With this in mind, using Connect Chat can become problematic. Every time a chat message is added against a record in ServiceNow that has worknote notifications, an email is generated and sent. For lengthy chat sessions this can generate a large volume of unwanted email notifications.

To combat this we need to stop an email notification from being sent if the origin of the worknote is from a chat message. after a bit of digging around the base system tables I came up with the following script include that provides a way of determining the origin of a worknote or comment on a record.

Type: Script Include

Name: chatChecker

var chatChecker = Class.create();

chatChecker.prototype = {

        initialize: function() {

        },

        check: function (tableName, recSysID){

                  //first we check if there is even a conversation associated to this incident...

                  var liveGroupProf = new GlideRecord('live_group_profile');

                  liveGroupProf.addQuery('table', tableName);

                  liveGroupProf.addQuery('document', recSysID);

                  liveGroupProf.query();

                  if (!liveGroupProf.hasNext()) {

                            //no profile found; then just send as normal.

                            return true;

                  }else{

                            // Found a profile, now check to see if there is a new chat message associated with it

                            liveGroupProf.next();

                            var liveFeedMessage = new GlideRecord('live_message');

                            liveFeedMessage.addQuery('group',liveGroupProf.sys_id);

                            liveFeedMessage.orderByDesc('sys_created_on');

                            liveFeedMessage.query();

                            liveFeedMessage.next();

                            if(liveFeedMessage.chat_message == true){

                                      return false;

                            }else{

                                      return true;

                            }

                  }

        },

        type: 'chatChecker'

};

Then on the notifications you'd like to stop when the trigger is a chat message, you can add the following code into the "Advanced Condition" field.

var chatChecker = new chatChecker();

answer = chatChecker.check(current.getTableName(), current.sys_id);

I hope this helps someone else!

12 REPLIES 12

Thanks Callum for your quick response !



A HI ticket is now opened.


For your information, we are on Istanbul Instance



I'll inform you about solution proposed.



Gwendal.


Hello,



As mentionned by Gwendal we have opened an HI ticket because livefeed is not populated by additional comments when commented incident is linked to a chat. Thus, the chatchecker doesnot work because the last livefeed in this case is necessary linked to a chat.



When the incident is not linked to a chat, additional comments are correctly send to live feed table.



So we need a fix to populate livefeed table in case of additionnal comments   on incident linked to a chat.


After that, chatcheker can do his job 🙂 !



Alexandre


alexandreamelin
Giga Contributor

SN has opened a Known error for this behavior even though it is working as designed since it is not the best user experience. This article contains a workaround you should be able to use to verify if the comments are coming from a Connect transaction or an incident update. KB0657223 - Connect Support chat sessions that continue after incident creation result in emails sen...