Service Portal: Add info message

gomathyshankar
Tera Contributor

Hi,

Whenever user submits the incident (something is broken)we get the below mentioned info message in the incident page.The same incident when we submit in portal it showing same message.We want to override this message as want to redirect to other page   in service portal .Could some please help me here.

incident.png

14 REPLIES 14

gomathyshankar
Tera Contributor

Hi,



Could some one please help me here.


chirag_bagdai
ServiceNow Employee
ServiceNow Employee

Hello !



I have created cloned widget   of "SC Catalog Item" in which I am displaying custom message and also redirecting users to homepage (custom changes will work for only one catalog item).



Please follow below steps for custom widget changes:



1. Server script changes :


This changes should work for only one catalog item so for that I have added below condition where you need to update the sys_id of catalog item.



data.sys_id = input.sys_id;


  else if(options.sys_id)


  data.sys_id = options.sys_id;


  else


  data.sys_id = $sp.getParameter("sys_id") || $sp.getParameter('sl_sys_id');



  if(data.sys_id == '186d917a6fab7980575967ddbb3ee4f2')


  data.custom_catalog_item = true;


  else


  data.custom_catalog_item = false;




2. Add $timeout in client controller function argument.


function ($scope, $http, spUtil, nowAttachmentHandler, $rootScope, $sanitize, $window, $sce, i18n,$timeout) {



3. Update issueMessage function script with below :


function issueMessage(n, table, sys_id) {


  var page = table == 'sc_request' ? 'sc_request' : 'ticket';


  if (c.options.page) {page = c.options.page;}


  if (c.options.table) {table = c.options.table;}


  var url = spUtil.format(c.options.url, {page: page, table: table, sys_id: sys_id});


  if (c.options.auto_redirect == "true") {


  $window.location.href = url;


  return;


  }




  var t = $scope.m.createdMsg + " " + n + " - ";


  t += $scope.m.trackMsg;


  t += ' <a href="' + url + '">' + $scope.m.clickMsg + '</a>';


  if(c.data.custom_catalog_item) {


            spUtil.addInfoMessage("Hi! This is Custom InfoMessage created. You will be redirected to homepage in 3 seconds....");


            $timeout(function(){


                      $window.location.href ="/sp";


            },3000);


  }


  else


            spUtil.addInfoMessage(t);


}



You need to replace "SC Catalog Item" widget with cloned widget in "sc_cat_item" page.


--


Output :



Screen Shot 2017-06-04 at 12.33.38 AM.png



Let me know for any question.


Does this solution work with Kingston?   I can't seem to find the issuemessage function!


It can change the message on the Record Producer page. Is there a way to put message after the redirection?

Thank you,

yltsai
Mega Guru

Did you get it to work?