GlideRecord Query with UI Macro

Sathya10
Tera Expert

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;amp;topicName=' + g_form.getValue('number') +': ' + g_form.getValue('short_description') + '&amp;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

8 REPLIES 8

@Sathya 

Any update on this?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

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

Hi,

how is the macro added to form?

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar / @Sathya10 :

 

You can use `g2:evaluate` (phase 2 Jelly processing) to access the `current` variable.