On Portal, after submitting a request, want to redirect to a page and then show the Info message

sn123
Kilo Contributor

Hi,

Please see the below Screenshot:

On submitting a request through Portal, i want to first redirect to sp_home page and then display below message on it:

find_real_file.png

Can anyone help, tried to update the client controller on widget with no success.

18 REPLIES 18

Good Morning,



I've noticed that you've pasted that same response 3 times in this thread.



You didn't state where exactly to put it and I've tried to use it and it doesn't seem to be working for me.



I placed this within the Client Script (since it's a javascript setTimeout) within the $scope.triggerOnSubmit = function(){ section.



Is there another place I should be putting this?



Thanks!



Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Hi Allen Andreas,



i have tried this tread which is Re: How to get url parameter value in the Client Script Service Portal?


try this link ..


it is working fine .if it is useful .select the helpful button ..


Gurpreet07
Mega Sage

Configure Options for sc_cat_item and you will find below options.


find_real_file.png


rini2
Giga Expert

Hi,



You could modify the Client Script of the corresponding widget. For example in the "SC Catalog Item" widget you can add something like


document.location = "/sp/";  



within the $scope.triggerOnSubmit function.



Though you would want to add a delay so the end user can see the successful submission message, which will get lost on the redirect.



Please mark it correct/Helpful based on Impact.



Thanks,


Rini


chirag_bagdai
ServiceNow Employee
ServiceNow Employee

Hello,



By using OOB features, you can redirect users to specific page but however you can't display the   message which you get after submission of request.



But still, if you are looking to display message on homepage, I think, below approach can be helpful.



-> After submitting request, redirect users to portal home


-> Store message in sessionStorage show that you can display that message in homepage after redirection


-> Create custom widget for homepage to show SessionStorage data (message)



Step 1 : Create clone of "SC Catalog Item" widget and make below changes :



// include $location in function parameters in client controller :


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



// Update issueMessage function in client controller with below script :



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;


  }



  $window.location.href = $location["$$path"];


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


  t += $scope.m.trackMsg;


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



  sessionStorage.request_success_msg = t;


  //spUtil.addInfoMessage(t);


  }



->I have added   $window.location.href = $location["$$path"]; so that after submission of request users will be redirected to the current portal & sessionStorage.request_success_msg for storing data in browser's session storage.



Step 2: Create custom widget which you need to add in homepage, below is the client controller script to display message:



function (spUtil) {


  /* widget controller */


  var c = this;


  if(sessionStorage.request_success_msg != '') {


    spUtil.addInfoMessage(sessionStorage.request_success_msg);


    sessionStorage.request_success_msg = '';


  }


}



Please let me know if you find any question for me.