{"id":564,"date":"2011-09-16T15:38:44","date_gmt":"2011-09-16T13:38:44","guid":{"rendered":"http:\/\/www.scsm.se\/?p=564"},"modified":"2011-09-16T15:38:44","modified_gmt":"2011-09-16T13:38:44","slug":"a-smarter-way-to-notify-the-assignee-when-the-affected-user-updates-his-incident","status":"publish","type":"post","link":"http:\/\/www.scsm.se\/?p=564","title":{"rendered":"A smarter way to notify the assignee when the affected user updates his incident"},"content":{"rendered":"<p>A common request is to be able to notify the assigned analyst of an incident whenever\u00a0the incident\u00a0has\u00a0been updated by the affected user. And for those who&#8217;s been reading my blog for a while know that I&#8217;ve described ways to do this before:<\/p>\n<p>Notify the assigned analyst when a customer has updated his incident (Exchange connector)<br \/>\n<a href=\"http:\/\/www.scsm.se\/?p=167\">http:\/\/www.scsm.se\/?p=167<\/a><\/p>\n<p>Minor SSP modifications, part 4 \u2013 Changing status of an incident when updated by the End user<br \/>\n<a href=\"http:\/\/www.scsm.se\/?p=501\">http:\/\/www.scsm.se\/?p=501<\/a><\/p>\n<p>Both of those two blogposts is built around changing the <strong>status<\/strong> of the incident to be able to trigger a notification to the assigned user of the incident to react upon. There is nothing wrong with that, it works pretty good in fact, but there is one flaw in this design. This flaw is related to the way the Exchange connector works and the fact that we are applying a template to the incident to set the status back to active (for those of you who doesn&#8217;t know what I&#8217;m talking about, please see <a href=\"http:\/\/www.scsm.se\/?p=167\">http:\/\/www.scsm.se\/?p=167)<\/a>.<\/p>\n<p>What if someone replies to an e-mail of an incident which has been closed? Well, based upon the configuration we did in the earlier blogpost mentioned above, the exchange connector will apply a template that sets the status back to active and the incident is re-opened. For some this might be acceptable, but for others, it&#8217;s not. I visited a customer a couple of days ago who thought this was great if the status of the incident was set to Resolved but not\u00a0if it was Closed. Instead, they wanted to notify\u00a0the end user\u00a0that he or she would have to\u00a0open a new incident and leave the old incident closed. There is no way to tell the Exchange connector to apply different templates depending on the current status of an incident, so I had to figure out another way to solve it.<\/p>\n<p>Since I couldn&#8217;t use the status of an incident to trigger the notifications, I figured we would have to add a new propery to work with instead.<\/p>\n<p>So here&#8217;s a smarter way to solve all this:<\/p>\n<p><strong>1.<\/strong> Extend the Incident class with a new boolean property. I will call my property &#8220;UpdatedByEndUser&#8221;.<br \/>\n(I won&#8217;t describe how to do this, but take a look at this blogpost if you need some help <a href=\"http:\/\/www.scsm.se\/?p=192\">http:\/\/www.scsm.se\/?p=192)<\/a><\/p>\n<p><strong>2.<\/strong> Create two incident templates &#8211; One who sets &#8220;UpdatedByEndUser&#8221; to True, and another who sets &#8220;UpdatedByEndUser&#8221; to False.<\/p>\n<p>This\u00a0is actually trickier than it sounds (but it&#8217;s not hard). The Extension tab is not accessible\u00a0on the form when creating a template &#8211; so what you would need to do is checking the Escalated checkbox for both these templates, then export the management pack in which these\u00a0templates are stored and change Escalated to UpdatedByEndUser. For the corresponding template, you will also have to change the value from True to False.\u00a0Take a look at the screenshot below:<\/p>\n<p><a href=\"http:\/\/www.scsm.se\/wp-content\/uploads\/2011\/09\/XML_Templates.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-570\" title=\"XML_Templates\" src=\"http:\/\/www.scsm.se\/wp-content\/uploads\/2011\/09\/XML_Templates-300x228.png\" alt=\"\" width=\"300\" height=\"228\" srcset=\"http:\/\/www.scsm.se\/wp-content\/uploads\/2011\/09\/XML_Templates-300x228.png 300w, http:\/\/www.scsm.se\/wp-content\/uploads\/2011\/09\/XML_Templates-1024x779.png 1024w, http:\/\/www.scsm.se\/wp-content\/uploads\/2011\/09\/XML_Templates.png 1182w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><strong>3.<\/strong> Edit the Exchange connector to apply the UpdatedByEndUser to True template when an incident is updated.<\/p>\n<p><strong>4.<\/strong> Edit the source code of the Self Service Portal to set this value to True if someones uses the portal to add a comment to their incident.<\/p>\n<p>Open\u00a0the source code for your\u00a0SSP (<a href=\"http:\/\/www.scsm.se\/?p=398)\">http:\/\/www.scsm.se\/?p=398)<\/a>. Then open the &#8220;Helper.cs&#8221; under WebParts and search for &#8220;\/\/If it is resolved then reactivate it by changing the status to Active&#8230; &#8221; &#8211; this should bring you to line 510.<\/p>\n<p>Add this code&#8230;<br \/>\n[c] requestDataItem[&#8220;UpdatedByEndUser&#8221;] = true;\u00a0[\/c]<\/p>\n<p>&#8230;to line 523 and line 535. Like this:<\/p>\n<p><a href=\"http:\/\/www.scsm.se\/wp-content\/uploads\/2011\/09\/CommentInSSP.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-574\" title=\"CommentInSSP\" src=\"http:\/\/www.scsm.se\/wp-content\/uploads\/2011\/09\/CommentInSSP-300x160.png\" alt=\"\" width=\"300\" height=\"160\" srcset=\"http:\/\/www.scsm.se\/wp-content\/uploads\/2011\/09\/CommentInSSP-300x160.png 300w, http:\/\/www.scsm.se\/wp-content\/uploads\/2011\/09\/CommentInSSP-1024x547.png 1024w, http:\/\/www.scsm.se\/wp-content\/uploads\/2011\/09\/CommentInSSP.png 1058w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Note: This is the untouched code. If you followed the blogpost &#8220;Minor SSP modifications, part 4 \u2013 Changing status of an incident when updated by the End user&#8221; the code should like\u00a0a little bit different and you might want to revert that change.<\/p>\n<p><strong>5.<\/strong> Create a two new workflows:<br \/>\n<strong>5a.<\/strong> One that triggers when UpdatedByEndUser changed from False to True and where the current status of the Incident is set to Active or Pending<br \/>\n<strong>5b<\/strong>. One that triggers when UpdatedByEndUser changed from False to True and where the current status of the Incident is set to Closed<\/p>\n<p>Both these workflows would then send an e-mail to the assigned user to inform he\/she that the incident has been updated, <span style=\"color: #ff0000;\">but they must also apply an template that sets the value of UpdatedByEndUser back to False<\/span>; otherwise the workflows won&#8217;t trigger on recurring updates.<\/p>\n<p><strong>6.<\/strong> You might also want to set UpdatedByEndUser to true when the end user closes the incident from the portal (as requested in this thread <a href=\"http:\/\/social.technet.microsoft.com\/Forums\/en-US\/administration\/thread\/83e3e998-cdde-4b4e-a83d-b17c08485531\/\">http:\/\/social.technet.microsoft.com\/Forums\/en-US\/administration\/thread\/83e3e998-cdde-4b4e-a83d-b17c08485531\/<\/a>)<\/p>\n<p>To do this, open up your Source Code for the SSP again.\u00a0The Close Request button is actually available on two pages: ViewAllRequests and RequestDetails, but both of these buttons uses a function called &#8220;CloseIncidentInternal&#8221;, so what we need to do is edit that particular function. This function is located in the Helper.cs file, so let&#8217;s open that file.<\/p>\n<p>The function itself start at line 411 (just search for CloseIncidentInternal to get there) but we need to add the following peice of code to line 489:<\/p>\n<p>[c]incidentDataItem[&#8220;UpdatedByEndUser&#8221;] = true;[\/c]<\/p>\n<p><a href=\"http:\/\/www.scsm.se\/wp-content\/uploads\/2011\/09\/CloseRequest.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-581\" title=\"CloseRequest\" src=\"http:\/\/www.scsm.se\/wp-content\/uploads\/2011\/09\/CloseRequest-300x123.png\" alt=\"\" width=\"300\" height=\"123\" srcset=\"http:\/\/www.scsm.se\/wp-content\/uploads\/2011\/09\/CloseRequest-300x123.png 300w, http:\/\/www.scsm.se\/wp-content\/uploads\/2011\/09\/CloseRequest.png 845w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Compile and deploy the new binaries.<\/p>\n<p><strong>7.<\/strong> Create another workflow that triggers when UpdatedByEndUser changes from False to True and where the status equals closed. Use this workflow to notify the assigned analyst that the end user has closed his\/hers incident.<\/p>\n<p>All done \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A common request is to be able to notify the assigned analyst of an incident whenever\u00a0the incident\u00a0has\u00a0been updated by the affected user. And for those who&#8217;s been reading my blog for a while know that I&#8217;ve described ways to do this before: Notify the assigned analyst when a customer has updated his incident (Exchange connector) [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-564","post","type-post","status-publish","format-standard","hentry","category-servicemanager"],"_links":{"self":[{"href":"http:\/\/www.scsm.se\/index.php?rest_route=\/wp\/v2\/posts\/564","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.scsm.se\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.scsm.se\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.scsm.se\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.scsm.se\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=564"}],"version-history":[{"count":16,"href":"http:\/\/www.scsm.se\/index.php?rest_route=\/wp\/v2\/posts\/564\/revisions"}],"predecessor-version":[{"id":584,"href":"http:\/\/www.scsm.se\/index.php?rest_route=\/wp\/v2\/posts\/564\/revisions\/584"}],"wp:attachment":[{"href":"http:\/\/www.scsm.se\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=564"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.scsm.se\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=564"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.scsm.se\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=564"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}