- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2024 12:52 AM
Looking to get the user_show_incidents UI Macro to work on Interactions and SCTASK's.
I've copied the user_show_incidents macro and amended for Interactions, and that works like a charm.
However, for SCTASK it doesn't filter on the user in requested for, and instead just shows all SCTASKS for all users.
Can anybody advise how I could tweak the script in this UI Macro to filter on the requested for, like it does for opened by on Incidents?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2024 07:50 AM
So I found that this just doesn't seem to work on the SCTASK table, as Requested For is a RITM (sc_req_item) table field. So tweaked the INC code to point at that table instead, and it works like a charm. It will show users RITM's, not SCTASK's, but it's what we need.
<?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_tasks_${jvar_guid}:${ref}"/>
<g:reference_decoration id="${jvar_n}" field="${ref}"
onclick="showRelatedList('${ref}'); "
title="${gs.getMessage('Show related catalog tasks')}" image="images/icons/tasks.gifx" icon="icon-tree-right"/>
<g:inline template="list2_js_includes.xml"/>
<script>
// show related list
(function() {
function decorationShow(element, original, changed, loading) {
var $refButton = $j(gel('${jvar_n}'));
$refButton.attr('role', 'button');
}
var n = '${jvar_n}'.replace(/./g, '');
var h = new GlideEventHandler('onLoad' + n, decorationShow, '${ref}');
g_event_handlers.push(h);
})();
function showRelatedList(reference) {
try {
var displayValue = g_form.getDisplayBox(reference).value;
var title = new GwtMessage().getMessage("Showing records related to: {0} ", displayValue);
var query = 'requested_for' + '=' + g_form.getValue('requested_for');
var gdw = new GlideModal('show_list');
gdw.setTitle(title);
gdw.setSize(750);
gdw.setPreference('focusTrap', true);
gdw.setPreference('table', 'sc_req_item_list');
gdw.setPreference('sysparm_query', query);
gdw.setPreference('title', 'A New Title');
gdw.render();
} catch (e) {
jslog('error showing related list');
jslog(e);
}
}
</script>
</j:jelly>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2024 02:37 AM
Anybody got any views on this please?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2024 07:50 AM
So I found that this just doesn't seem to work on the SCTASK table, as Requested For is a RITM (sc_req_item) table field. So tweaked the INC code to point at that table instead, and it works like a charm. It will show users RITM's, not SCTASK's, but it's what we need.
<?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_tasks_${jvar_guid}:${ref}"/>
<g:reference_decoration id="${jvar_n}" field="${ref}"
onclick="showRelatedList('${ref}'); "
title="${gs.getMessage('Show related catalog tasks')}" image="images/icons/tasks.gifx" icon="icon-tree-right"/>
<g:inline template="list2_js_includes.xml"/>
<script>
// show related list
(function() {
function decorationShow(element, original, changed, loading) {
var $refButton = $j(gel('${jvar_n}'));
$refButton.attr('role', 'button');
}
var n = '${jvar_n}'.replace(/./g, '');
var h = new GlideEventHandler('onLoad' + n, decorationShow, '${ref}');
g_event_handlers.push(h);
})();
function showRelatedList(reference) {
try {
var displayValue = g_form.getDisplayBox(reference).value;
var title = new GwtMessage().getMessage("Showing records related to: {0} ", displayValue);
var query = 'requested_for' + '=' + g_form.getValue('requested_for');
var gdw = new GlideModal('show_list');
gdw.setTitle(title);
gdw.setSize(750);
gdw.setPreference('focusTrap', true);
gdw.setPreference('table', 'sc_req_item_list');
gdw.setPreference('sysparm_query', query);
gdw.setPreference('title', 'A New Title');
gdw.render();
} catch (e) {
jslog('error showing related list');
jslog(e);
}
}
</script>
</j:jelly>