UI macro failed for Requested For
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-20-2024 07:48 AM
Hello, everyone.
There is a UI macro in which agents can click to open Microsoft Teams. It works fine for the caller and assigned to in the Incident form, but it is not in RITM. I guess that is due to the dot walking (request.requested_for) field being used on the RITM form. What could be fixed in the script below?
<?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}"/>
<a id="${jvar_n}"
onChange="onChange('${ref}');"
onclick="invokeChat('${ref}');"
name="${jvar_n}"
onmouseout="lockPopup(event)"
tabindex="0"
>
<img border="0" src="Microsoft_Teams_16x16.png" width="28" height="28" title="${gs.getMessage('Open Teams chat')}" />
</a>
<script>
function onChange(element, original, changed, loading) {
var visibility = 'visible';
var sysID = g_form.getValue('assigned_to');
if (!sysID)
visibility = 'hidden';
var e = gel('${jvar_n}');
e.style.visibility= visibility;
}
function invokeChat(reference) {
var number = g_form.getValue('number');
var short_desc = g_form.getValue('short_description');
var s = reference.split('.');
var tableName = s[0];
var referenceField = s[1];
var v = g_form.getValue(referenceField);
if (!v){
v = g_form.getValue('sc_req_item.request.requested_for');
}
var email;
var gr = new GlideRecord('sys_user');
if (gr.get(v)) {
email = gr.email;
firstName = gr.first_name
}
var url = 'msteams:/l/chat/0/0?users=' + email + '&amp;message=Hi ' + firstName + ', this is regarding ticket: ' + number + ' - ' + short_desc;
var w = getTopWindow();
w.open(url);
}
</script>
</j:jelly>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-20-2024 08:25 AM
Hi @tsoct
You can use getReference which avoids dot-walking and allows you to work
var v = g_form.getReference('sc_req_item.request.requested_for');
v.get(function(refRecord) // call back function
var requestedForName = refRecord.name; // name of requested for
Mark it helpful and Accept Solution!! If this helps you to understand.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-20-2024 08:39 AM
Thanks. I can see name passing correctly but email is undefined.
<?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}"/>
<a id="${jvar_n}"
onChange="onChange('${ref}');"
onclick="invokeChat('${ref}');"
name="${jvar_n}"
onmouseout="lockPopup(event)"
tabindex="0"
>
<img border="0" src="Microsoft_Teams_16x16.png" width="28" height="28" title="${gs.getMessage('Open Teams chat')}" />
</a>
<script>
function onChange(element, original, changed, loading) {
var visibility = 'visible';
var sysID = g_form.getValue('assigned_to');
if (!sysID)
visibility = 'hidden';
var e = gel('${jvar_n}');
e.style.visibility= visibility;
}
function invokeChat(reference) {
var number = g_form.getValue('number');
var short_desc = g_form.getValue('short_description');
var s = reference.split('.');
var tableName = s[0];
var referenceField = s[1];
var v = g_form.getReference('sc_req_item.request.requested_for');
v.get(function(refRecord) // call back function
var requestedForName = refRecord.name; // name of requested for
var requestedForEmail = refRecord.email; // email of requested for
var url = 'msteams:/l/chat/0/0?users=' + requestedForEmail + '&amp;message=Hi ' + requestedForName + ', this is regarding ticket: ' + number + ' - ' + short_desc;
var w = getTopWindow();
w.open(url);
}
</script>
</j:jelly>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-20-2024 10:20 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-20-2024 10:45 AM
Hi @SK Chand Basha ,
Yes. By the way, the populated name doesnt seems to be the name of requested for, but it grabbed the name of Assigned to when the teams url open up