Anyone know an easy way to get the ref_contributions to render in a specific order?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2015 01:21 PM
Anyone know an easy way to get the ref_contributions to render in a specific order? I have two on the caller field on our incident form, one just shows when the caller is a VIP and I would like it to render after all others. tried changing the order of the ref_contributions attribute but that did not help. Right now I'm looking at a client script to do it but that seams like the ugly way to do it. Hoping someone knows an easy way...
Here is the code if anyone is interested, I changed it from a client script because in Fuji the icon did not really display well.
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<j:set var="jvar_n" value="show_vip:${ref}"/>
<a id="${jvar_n}"
name="${jvar_n}"
style="visibility: hidden"
>
<img border="0" src="images/icons/vip.gif" title="${gs.getMessage('VIP')}" alt="${gs.getMessage('VIP')}"/>
</a>
<script>
//
// show icon if caller is VIP, hide if not
//
function onChange_show_vip(control, oldValue, newValue, isLoading) {
var callerLabel = $('label.incident.caller_id');
var callerField = $('sys_display.incident.caller_id');
if (!callerLabel || !callerField)
return;
if (!newValue) {
gel('${jvar_n}').style.visibility = "hidden";
callerField.setStyle({color: ""});
return;
}
g_form.getReference('caller_id', vipCallerCallback);
}
function vipCallerCallback(caller) {
var callerLabel = $('label.incident.caller_id').down('label');
var callerField = $('sys_display.incident.caller_id');
if (!callerLabel || !callerField)
return;
//check for VIP status
if (caller.vip == 'true') {
//Show VIP icon
gel('${jvar_n}').style.visibility = "visible";
//Set Field color
callerField.setStyle({color: "red"});
} else {
gel('${jvar_n}').style.visibility = "hidden";
callerField.setStyle({color: ""});
}
}
// create a handler
var h = new GlideEventHandler('onChange_incident_show_vip', onChange_show_vip, '${ref}');
g_event_handlers.push(h);
</script>
</j:jelly>
- Labels:
-
User Interface (UI)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2015 09:43 AM
So I finally found a way to move my icon, using this javascript
addLoadEvent(function(){
// create a handler
var h = new GlideEventHandler('onChange_incident_show_vip', onChange_show_vip, '${ref}');
g_event_handlers.push(h);
$("view.incident.caller_id.no").insert({
before: gel("${jvar_n}")
});
});
You apparently cannot use jQuery anymore to get fields based on ID in the DOM, you have to use prototype, which is really frustrating.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2017 11:29 AM
As a side note to this I found the jQuery will work as long as you escape the periods.
So
$j("view\.incident\.caller_id\.no")
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2015 10:31 AM
Ok, for completeness it turns out my issue was that one of my ref_contributions was not rendering at all, but they do render in the order specified.
If you would like the icon at the end of the line including the default icons you can use this.
$j("a[data-ref='incident.caller_id']").after(gel("${jvar_n}"));
That will put the icon for the UI Macro after the hover over icon that has the popup of the user information, which is what I was looking for.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2015 12:52 PM
Hello Drew, I am trying to add two icons next to the Requestor's field. One to show all their tickets and the other to show the active tickets only.
I am using ref_contributions and calling two marcos like this.
What happens is that when the first icon is pushed it shows all the tickets by the requester for a split second and then right away shows the active tickets
What's wrong with the above call.
Any help would be greatly appreciated.
The first macro is shown below. The second one is similar, but with a query to show active tickets.
<?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_tickets_${jvar_guid}:${ref}"/>
<g:reference_decoration id="${jvar_n}" field="${ref}"
onclick="showRelatedList('${ref}'); "
title="${gs.getMessage('Show tickets for user')}" 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 = s[0];
var referenceField = s[1];
var url = tableName + '_list.do?';
url += '&amp;';
var v = g_form.getValue(referenceField);
url += 'sysparm_query=' + referenceField + '=' + v;
var w = getTopWindow();
w.popupOpenFocus(url, 'related_list', 950, 700, '', false, false);
}
</script>
</j:jelly>
Thanks,
Shalini
