- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2019 07:38 AM
Hi,
When I "Submit" a Service catalog item on service Portal, the request page (sc_request) opens.
I would like a rediction of this submit to ritm page instead sc_request page.
I know I have to modifiy the clone of the widget "SC Catalog Item" but I don't know how.
Any idea ?
Thanks for your help,
Solved! Go to Solution.
- Labels:
-
Service Portal Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2019 08:55 AM
Hi there,
I am not sure it is relevant for you anymore, but still, in case someone else needs it, this is what worked for me:
1. Clone the SC Catalog Item widget
2. change the client script:
(look for "$location.search('id=sc_request&is_new_order..." around line 510)
//$location.search('id=sc_request&is_new_order=true&table=sc_request&sys_id=' + a.sys_id); //--> we do not want to redirect to the sc_request page
c.data.myrequest = a.sys_id;
c.server.update();
setTimeout(function(){
var ritmid = c.data.ritmId;
$location.search('id=form&table=sc_req_item&view=ess&sys_id=' + ritmid);
}, 400);
}
3. and in the server script, arounbd line 11, right after return;, add
if(input) {
if(input.myrequest != undefined) {
var ritm = new GlideRecord('sc_req_item');
ritm.addQuery('request',input.myrequest); //from line 514 in the client script ritm.query();
//If exactly one RITM is returned, pass to the Client Controller to redirect user
if(ritm.next()) {
data.ritmId = ritm.getUniqueValue();
}
}
That's it.
harel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2021 12:05 PM
Right now when i am trying to submit after making the change using your original solution here I land on blank screen with "Record not found" message and the url I have is the following:
https://eagledev.service-now.com/sp?id=form&table=sc_req_item&view=ess&sys_id=undefined
Please advise.
Thanks,
Johannes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2021 12:39 PM
Hi,
What is the homepage? -> your index page. The landing where users see the search and widgets.
What changes did you make to the form widget? are you using the homepage widget I suggested above? Basically, the form widget adds the sys id of the item to the URL and redirects you to the home page. This lines does it.
$location.search('/sp?&newticket=true&table=sc_request&sys_id=' + a.sys_id);// --> direct to homepage and add &newticket=true
The a.sys_id is the request sys id (not the item's sys id) and the widget I added on the homepage takes it from the URL and queries it. It then extracts the ritm link / number.
Can you post the relevant part of your code so we can have a look?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2021 01:21 PM
Hi oharel,
So right now I am using your original solution which was to change client script and the server script of the SC Catalog Item widget.
This is the change I have in the client script (please client script code attachment).
This is what i have in the server script (Please see server script attachment)
That's all I have for now and it does not work, instead it gives me the output I mentioned above.
So now I am trying to pursue your latest solution which is to use the homepage widget and I was getting confused with that. So are you saying that I should create a new widget like you have here and then drop it inside the index page? If so then the confusion I have is at what point will it be invoked. Please advise.
Thanks,
Johannes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2021 02:00 PM
The server side looks pretty similar to what I have.
The client side is a bit different: note that I actually commented out a section. Also, the lines are a bit different than yours.
As for the widget on the index page (yes, it is there. since it does not have an HTML code, it is "hidden"). It loads when the page loads. That's why it is easy to use. The server part does your work for you. It reads the url and shows a message according to what you set it to.
So for instance:
(function() {
/* populate the 'data' object */
/* e.g., data.table = $sp.getValue('table'); */
if($sp.getParameter("newticket") == 'true'){ //<-- newticket is added in the client script
gs.addInfoMessage('Thank you for submitting ' + TicketReferral() +'. Notifications regarding its progress will be sent to your email.' );
}
function TicketReferral() {
var myurl;
if($sp.getParameter("table") == 'sc_request'){ //the table is in the url as well
var ri = new GlideRecord('sc_req_item');
ri.addQuery('request', $sp.getParameter("sys_id")); //taken from the url
ri.query();
if(ri.next()) {
myurl = '<a href=/snow?view=ess&id=form&table=sc_req_item&sys_id='+ ri.sys_id + '">' + ri.number + '</a>'; //building the url
return myurl; //reutrning it to the infoMessage
}
}
}
})();
harel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2021 03:27 PM
Hi, I got it to work this time, thank you very much for your help.
Johannes