- 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
‎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
‎02-09-2017 07:14 AM
Hello,
I am also trying to implement similar configurations in my instance, but no luck. If you don't mind, can you please share the updated code.
Thanks in advance.
Regards,
Jai
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2017 09:49 AM
Can you send me the script that redirects to the incident record.
Ont the Service Portal homepage I created a incident widget. It shows the incident number and short description but when I click on that it shows 404 error instead of showing the record.
Not sure where do I change script in HTML and client controller. I cloned My requests Widget and made some changes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-13-2017 10:55 AM
I am using the window.location global to redirect to the resultant url
#table - either RITM or INC (can be any other table set as target in record producer)
#sys_id - sys_id of the record
#these are part of the issueMessage function
var url = "?id=ticket&table="+table+"&sys_id="+sys_id+"&view=sp";
$window.location = url;