Show tasks by requested for user

Baggies
Kilo Guru

I am working for a company that wants to employ a New Call feature for their service desk. Service Now Guru has such an app. for download (for which I thank them mightily) But one of the requirements our end users have asked for, is that when you insert a Requested For name from the sys_user table, that the form also show any open tasks by that users. Kind of like a related list, or UI Macro by the requested_for field.
The New Call module does not actually create a record, so I think this may be where the stumbling block is. I wonder if anyone else has tackled such a request.
The Service Desk has asked that as soon as a name goes into the requested_for field, that they have access to the users open tasks. Many Thanks for ANY response, or suggestions, Mark S.

13 REPLIES 13

Mark Stanger
Giga Sage

You can do this with a UI macro. Personalize the dictionary for the 'Requested for' field on the New Call form and add the 'ref_contributions=caller_show_incidents' attribute. Then create a macro named 'caller_show_incidents' with the following XML. Unfortunately, you'll have to have 2 separate macros, one for incidents, and another for requests to be able to see everything since they aren't part of the task table.



<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:evaluate var="jvar_guid" expression="gs.generateGUID(this);" />
<j:set var="jvar_n" value="show_incidents_${jvar_guid}:${ref}"/>
<g:reference_decoration id="${jvar_n}" field="${ref}"
onclick="showRelatedList('${ref}'); "
title="${gs.getMessage('Show related incidents')}" image="images/icons/tasks.gifx"/>

<script>
// show related list
// todo: should be part of the PopupWindow class
// todo: needs new stack name
function showRelatedList(reference) {
var s = reference.split('.');
var tableName = 'incident';
var referenceField = s[1];
var url = tableName + '_list.do?';
url += '&amp;';
var v = g_form.getValue(referenceField);
url += 'sysparm_query=' + 'caller_id' + '=' + v;

var w = getTopWindow();
w.popupOpenFocus(url, 'related_list', 950, 700, '', false, false);
}

</script>
</j:jelly>


Baggies
Kilo Guru

Thanks Mark S. I was looking at the "user_show_incidents" UI macro, but it seems to give me all open incidents, not just for the specific user. This worked just as expected. Mark S.


Baggies
Kilo Guru

I can get either one icon to show at a time, but not 2. I am using the atributes "ref_contributions=caller_show_incidents, ref_contributions=caller_show_requests. Both work fine, just cannot get them to work together. The script for the UI macro for requests is a modified version of Mr. Sanger's script is:

<?xml version="1.0" encoding="utf-8"?>




onclick="showRelatedList('${ref}'); "
title="${gs.getMessage('Show related requests')}" image="images/icons/tasks.gifx"/>

<script></script>// show related list
// todo: should be part of the PopupWindow class
// todo: needs new stack name
function showRelatedList(reference) {
var s = reference.split('.');
var tableName = 'sc_request';
var referenceField = s[1];
var url = tableName + '_list.do?';
url += '&';
var v = g_form.getValue(referenceField);
url += 'sysparm_query=' + 'requested_for' + '=' + v;

var w = getTopWindow();
w.popupOpenFocus(url, 'related_list', 950, 700, '', false, false);
}




I will "play around" with it some more and post my findings.


You can only have a single 'ref_contributions' attribute. Separate multiple macros with a semicolon.
ref_contributions=caller_show_incidents;caller_show_requests