Pring Lat 5 records of current logged in user
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2024 02:34 AM
I am sure the below script will print the last 5 records created on the system but am looking to print last 5 records assigned to the logged in user , could anyone please help me with the change on the below script.
var gr = new GlideRecord('incident);
gr.orderByDesc('sys_created_on');
gr.SetLimit(5);
gr.query();
while(gr.next(){
gs.print('incident number: '+gr.number);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2024 04:12 AM
Please use this :
var currentUser = gs.getUserID();
var gr = new GlideRecord('incident');
gr.addQuery('caller_id='+currentUser);
gr.orderByDesc('sys_created_on');
gr.SetLimit(5);
gr.query();
while(gr.next()){
gs.print('incident number: '+gr.number);
}
Thanks & Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2024 12:26 AM
@Amit Verma Thanks for the response but this is not working , could you please provide any other idea to achieve the same.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2024 12:43 AM
Can you please let me know where you are running this script ? Also, any errors being thrown when you run this ?
Thanks & Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-21-2025 07:14 PM