- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2017 08:46 AM
In our Service Portal that was developed by a third party, we have a section along the top of the screen with personalised options for the logged in user
Clicking on the User name brings up the user record and they can get to the Knowledge base and Service Catalog from this section too. Also, as you can see above, there is a drop down where the user can view their open tickets. What I'd like to do is change this so that the user can also view tickets raised by their team colleagues as well as themselves (each user record has a populated team field - u_team in the sys_user table) - how can I do this?
Solved! Go to Solution.
- Labels:
-
Service Portal Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2017 12:22 AM
Hi David,
You need to modify 'My Requests' widget's Server script - http://instancename.service-now.com/sp_config?id=widget_editor&sys_id=f1672671d7301200a9addd173e24d4... as follows.
1. Created a new function to get current user' team.
function getMyTeam(userID){
gs.log(userID);
var user = new GlideRecord('sys_user');
if(user.get(userID))
return user.team;
}
2. Replace the line 'gr.addEncodedQuery('requested_for=javascript:gs.getUserID()');' with the below lines
var myTeam = getMyTeam(gs.getUserID());
gr.addQuery('team', myTeam);
3. Change the line 'var gr = new GlideRecordSecure('sc_request');' to use GlideRecord as below
var gr = new GlideRecord('sc_request');
With all the changes, it would look like this.
Hope this helps. Mark the answer as correct/helpful based on impact.
Thanks
Antin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2017 12:22 AM
Hi David,
You need to modify 'My Requests' widget's Server script - http://instancename.service-now.com/sp_config?id=widget_editor&sys_id=f1672671d7301200a9addd173e24d4... as follows.
1. Created a new function to get current user' team.
function getMyTeam(userID){
gs.log(userID);
var user = new GlideRecord('sys_user');
if(user.get(userID))
return user.team;
}
2. Replace the line 'gr.addEncodedQuery('requested_for=javascript:gs.getUserID()');' with the below lines
var myTeam = getMyTeam(gs.getUserID());
gr.addQuery('team', myTeam);
3. Change the line 'var gr = new GlideRecordSecure('sc_request');' to use GlideRecord as below
var gr = new GlideRecord('sc_request');
With all the changes, it would look like this.
Hope this helps. Mark the answer as correct/helpful based on impact.
Thanks
Antin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2017 01:56 PM
Hi David,
Did you try what I suggested above? If the suggestion has answered your questions, can you please mark it as 'correct' to help the community?
Thanks
Antin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2017 07:57 AM
Hi Antin,
Apologies for the delayed response, I'm taking what you are using and applying it to a couple of other things at the moment, but I'll make your response as correct as it has been useful to me.
Thank you again
David
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2017 08:07 AM
Hi David,'
Glad it works for you. I think you haven't marked the answer as 'Correct' (you have just marked as 'helpful'). Can you please mark it as 'correct' so that it helps other community users looking for similar help?
Thanks
Antin