GlideRecord Query with UI Macro
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2022 09:59 PM
Hi All,
I'm trying to implement a feature that allows the user to open a group chat with the assignment group members with the click of a button.
I'm trying to query the sys_user_grmember table with the assignment group info on the ticket to get the email of the members to append to the Teams deep link URL
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core"
xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<a class="btn-default;" id="${jvar_n}" onclick="invokeChat('${ref}');">
<img src="teams.png" width="25" title="Teams Chat" alt="${gs.getMessage('Click to open Teams chat')}" />
</a>
<g:evaluate var="jvar_gr" object="true">
var gr = new GlideRecord('sys_user_grmember');
var assign_grp = g_form.getValue('assignment_group');
gr.addQuery('group',assign_grp);
gr.query();
while(gr.next()){
user += gr.user.email + ',';
}
user;
</g:evaluate>
<script>
function invokeChat(reference) {
var prefix = 'https://teams.microsoft.com/l/chat/0/0?users=';
var firstname = g_form.getReference('u_requestor').first_name;
var user1 = jelly.jvar_gr;
var subject = '&amp;topicName=' + g_form.getValue('number') +': ' + g_form.getValue('short_description') + '&amp;message=Hi All, Can you please give me an update ?';
var w = getTopWindow();
var url = prefix + user1 + subject;
w.open(url);
}
</script></j:jelly>
It looks like the g_form object is not defined in the evaluate section. Any assistance will be deeply appreciated.
TIA
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2022 09:38 PM
Any update on this?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2022 07:12 PM
Hi Ankur,
Unfortunately, I was not able to get the value of assignment group using any of the current methods (getValue/getDisplayValue/using current.assignment_group directly). I resorted to creating a custom field on the incident table to store the group member's email IDs which I then used in the script to create the URL.
Regards.
Sathya R
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2022 12:19 AM
Hi,
how is the macro added to form?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2023 04:43 PM
Hi @Ankur Bawiskar / @Sathya10 :
You can use `g2:evaluate` (phase 2 Jelly processing) to access the `current` variable.