Get Caller or requested for details in a task list view
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2015 01:56 AM
I created a list view from the task table which shows all active requests and Incidents. But I want a create a new field which shows either the requested_for or caller_id.
I don't want two separate fields. Is this straight forward and what steps should I take?
Thanks,
Adam,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2021 12:11 AM
Hi, Pradeep.
Will this also work if I want to pull user tickets on task table for Incident and catalog tasks?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2015 05:42 AM
Hi Adam,
The main issue with these 2 fields is that they are reference fields, therefore having a new field on task and just copying their value will only bring a sys_id in the field, which is not useful when displaying it in list view.
I created as a test a script field on task and applied a calculated script like:
if (current.sys_class_name == 'incident' && current.caller_id){
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id',current.caller_id)
gr.query()
while(gr.next()){
current.someone = gr.user_name;
}
} else if (current.sys_class_name == 'sc_request' && current.requested_for) {
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id',current.requested_for)
gr.query()
while(gr.next()){
current.someone = gr.user_name;
}
} else {
current.someone='No user';
}
If I open any incident or sc_request after I add the field on the form I see the correct value as I wanted (user_name). Incident/sc_request list view also displays the user. Somehow for task list view is not working that well so far, therefore you might need to play a little bit with the script or dig deeper, but I assume you understand the idea behind.
Regards,
Sergiu

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2015 07:34 AM
Hi Adam,
As everyone has suggested, I would also suggest creating a new field on the task table (lets just call it User) and then fill it using a business rule (on before insert and update). You could create the business rule to run on the task table but under condition you would ensure it only really runs on incident and requested item. Then depending on the table, fill the User field from either caller_id or requested_for.
Obviously, you would also need to create a small script in background scripts to fill the already created INC/RITM.
If you need me to create the script, give me a shout
Regards
Oliver