- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2017 09:26 AM
Hello Community,
I am trying to modify the out of box "SC Catalog Item" widget which displays the request/incident number using spUtil.addInfoMessage() after submission of the item. Instead of just displaying the number, I want it to redirect to the specific record. For incident, it works fine. For request, I want to redirect the user to the RITM record instead of the REQ record. I believe I need to fetch the RITM sys_id from the server script for this.
See the code below. How do I access the sys_id and number of the RITM within the client controller?
In client controller:
//req_id holds the sys_id of the REQ
$scope.server.get({request_id:req_id}).then(function(r){
//how do I access the sys_id and number of the RITM here?
//$scope.data doesn't have these parameter
//how do I make use of 'r' to access those values set in the server script? I checked JSON stringifying of 'r'. It didn't help.
//Checked the value of r.data.ritm_id / r.data.ritm_number, it returns undefined
});
In server script:
if(input){
if(input.request_id){
// Debugging gives me the correct value of sys_id of the REQ
var gr = new GlideRecord('sc_req_item');
gr.addQuery('request',input.request_id);
gr.query();
if(gr.next()){
data.ritm_id = gr.sys_id;
data.ritm_number = gr.number;
}
}
}
else {
// other scripts
}
Thanks,
Probir
Solved! Go to Solution.
- Labels:
-
Service Portal Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2017 11:31 AM
I was able to fix it. Had to convert the values to string.
In server script:
if(input){
if(input.request_id){
// Debugging gives me the correct value of sys_id of the REQ
var gr = new GlideRecord('sc_req_item');
gr.addQuery('request',input.request_id);
gr.query();
if(gr.next()){
data.ritm_id = gr.sys_id.toString();
data.ritm_number = gr.number.toString();
}
}
}
else {
// other scripts
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2017 04:57 AM
I tried this code and it is not working. I am on Jakarta. Is there anything else I need to update other than client and server script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-20-2017 04:51 AM
Hello, It's work in Helsenki, but I having upgrading my dev plateform in Jakarta ; & some form are redirect in RITM, but 2 form are not redirect & frozen to "Submit..."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-21-2017 03:37 AM
Thanks a lot Jason
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-10-2019 12:36 PM
Hi Jason, I'm looking to do the same thing...redirect user to the new RITM after catalog item submit (we are not using the cart, so each REQ has only 1 RITM).
I'm using your scripts that you posted but it's not working...should I be able to copy and paste the full scripts you posted for server and client script? I'm on London. thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-15-2018 02:55 AM
Hi,
we have a similar requirement, to redirect the create incident record producer to ticket form page, post submission.
In this case, I am successfully able to redirect, to ticket form page, but unable to fetch the sys id.
$scope.triggerOnSubmit = function(item_sys_id){
$scope.data.sc_cat_item.item_action = "order";
$scope.data.sc_cat_item.quantity = c.quantity;
$scope.data.id=item_sys_id;
//alert($scope.data.id);
if (g_form){
g_form.submit();
$window.location = "https://sadaradev.service-now.com/sp?id=ticket&table=incident&sys_id=" +$scope.data.id;
get();
}
}
function get(){
spUtil.update($scope);
}
In this case, $scope.data.id is not fetching the sys_id of the current incident. Hence, in this case,i am unable to redirect to the exact page.