How to modify a submission message after a request is submitted

gaurip
Mega Expert

Hi,

I'm working on a Service Portal. I want to modify submission message (in green) when a request is submitted. Screenshot as below.

find_real_file.png

I want to display Requested Item Number instead of Request Number. After investigating this further, I have come to the conclusion that we'll have to modify the REST call in Client Controller. Not sure what I need to do in order to get RESPONSE as Requested Item and not as Request.

$http.post(spUtil.getURL('sc_cat_item'), t).success(function(response) {

                      var a = response.answer;

                      var n = a.number;

                   

                      $scope.$emit("$$uiNotification", response.$$uiNotification);

                      $scope.$emit("$sp.sc_cat_item.submitted", a);

                      if (n)

                              issueMessage(n, a.table, a.sys_id);

                      $scope.submitting = false;

                      $scope.submitButtonMsg = $scope.m.submittedMsg;

});

Can anyone suggest how to achieve this?

Thank you.

-Gauri

9 REPLIES 9

Hi Bobby,



No, I haven't tried what Nathan has suggested above. We decided not to go ahead with this requirement. You can give it a go.



You can also contact ServiceNow by raising a ticket so they will let you know if they have any update on this bug.



-Gauri


Hi,



You can edit the "Created..." message by editing a Widget. The Widget you are seeking is called SC Catalog Item (widget-sc-cat-item). Clone that widget to begin making your changes.



The logic for generating the messages exists in the Client Script.



Edit the function at the bottom of the Client Script, called issueMessage(). This is what is called after the form has been submitted, and the order has been processed.


function issueMessage(n, table, sys_id) {


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


  var t = "${Created} " + n + " - ";


  t += "${track using 'Requests' in the header or}";


  t += ' <a href="?id=' + page + '&table=' + table + '&sys_id=' + sys_id + '">' + "${click here to view}" + '</a>';


  spUtil.addInfoMessage(t);


}


Once you have made the changes, simply replace the OOB Widget Instance that appears on the page "sc_cat_item", with your newly cloned one.



If you want to see where issueMessage() gets called, take a peek at the getOne() function for its use.



I am unsure where the "assigned to" message gets called from, but it is not in the Widget from what I can tell.




Thanks.


ssaha
Giga Contributor

I want to edit the message that is being displayed after creating an Incident.



I want to change "track using "Requests"...." to "track using "Incident"...".



If I clone the widget and edit, it can be done I guess, but then when I create a Request, I think it will display "track using "Incident"...". I also want to know if I clone the widget and give it a new name, how to use the newly created widget for displaying the message.



Your help is much appreciated.


Please replace below line in above code



function issueMessage(n, table, sys_id) {


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


  var t = "${Created} " + n + " - ";


  t += "${track using 'Incident' in the header or}";


  t += ' <a href="?id=' + page + '&table=' + table + '&sys_id=' + sys_id + '">' + "${click here to view}" + '</a>';


  spUtil.addInfoMessage(t);


}



Mark it correct/helpful based on impact.



Thanks


Sangeetha22
Giga Contributor

Hi ,

        you have to call the glide record for sc_req_item and then pass the variable inside to client conroller

then you have to write the client controller to query the ritm instead of Request table.

        Let me know if you have any queries.