<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: Get the count of records in a reference variable in Developer forum</title>
    <link>https://www.servicenow.com/community/developer-forum/get-the-count-of-records-in-a-reference-variable/m-p/1397440#M54366</link>
    <description>&lt;P&gt;Hello Ankur,&lt;/P&gt;
&lt;P&gt;If the count is 1,still the value is not getting set.I checked with logs,the answer value we are getting in client script is only 'sys_idIN'.&lt;BR /&gt;If the count is more than 1,scenario is working fine.&lt;/P&gt;
&lt;P&gt;I tried in background script,I am getting the single groups sys_id,if the count is one.&lt;/P&gt;</description>
    <pubDate>Thu, 30 Apr 2020 04:24:34 GMT</pubDate>
    <dc:creator>Kumar60</dc:creator>
    <dc:date>2020-04-30T04:24:34Z</dc:date>
    <item>
      <title>Get the count of records in a reference variable</title>
      <link>https://www.servicenow.com/community/developer-forum/get-the-count-of-records-in-a-reference-variable/m-p/1397434#M54360</link>
      <description>&lt;P&gt;Hello All,&lt;/P&gt;
&lt;P&gt;I am using a refernce qualifier on Group variable which works fine.&lt;/P&gt;
&lt;P&gt;Now I want to count the "number of groups" that group variable is showing.If my group(s) count is one then I need to set the one group in the group field and it should be read only.if the group count is greater than 1 then user will select the groups.&lt;/P&gt;
&lt;P&gt;How to achieve this?Below is my reference qualifier code:&lt;/P&gt;
&lt;P&gt;Reference qualifier:javascript: new getgroupcontext().getgrpcontext(current.variables.role2);&lt;/P&gt;
&lt;P&gt;var getgroupcontext = Class.create();&lt;BR /&gt;getgroupcontext.prototype = Object.extendsObject(AbstractAjaxProcessor, {&lt;BR /&gt;getgrpcontext : function(role)&lt;BR /&gt; {&lt;BR /&gt; &lt;BR /&gt; //var role = this.getParameter('sysparm_query');&lt;BR /&gt; var groups = [];&lt;BR /&gt; var gr = new GlideRecord('sys_group_has_role');&lt;BR /&gt; gr.addQuery('role.name',role);&lt;BR /&gt; gr.query();&lt;BR /&gt; &lt;BR /&gt; while(gr.next())&lt;BR /&gt; {&lt;BR /&gt; //gs.log("@362363"+gr.group+"NOWROLE"+gr.role.name);&lt;BR /&gt; groups.push(gr.group);&lt;BR /&gt; &lt;BR /&gt; &lt;BR /&gt; }&lt;BR /&gt; return 'sys_idIN' + groups.toString();&lt;BR /&gt; },&lt;BR /&gt; type: 'getgroupcontext'&lt;BR /&gt;});&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Apr 2020 12:19:37 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/get-the-count-of-records-in-a-reference-variable/m-p/1397434#M54360</guid>
      <dc:creator>Kumar60</dc:creator>
      <dc:date>2020-04-28T12:19:37Z</dc:date>
    </item>
    <item>
      <title>Re: Get the count of records in a reference variable</title>
      <link>https://www.servicenow.com/community/developer-forum/get-the-count-of-records-in-a-reference-variable/m-p/1397435#M54361</link>
      <description>&lt;P&gt;Can you try something as below (untested).&lt;/P&gt;
&lt;PRE class="language-markup"&gt;&lt;CODE&gt;var getgroupcontext = Class.create();
getgroupcontext.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getgrpcontext : function(role)
{

//var role = this.getParameter('sysparm_query');
var countis='';
var x;
var groups = [];
var gr = new GlideRecord('sys_group_has_role');
gr.addQuery('role.name',role);
gr.query();

while(gr.next())
{
//gs.log("@362363"+gr.group+"NOWROLE"+gr.role.name);
countis=gr.getRowCount();
if(countis==1)
{
x=gr.group.sys_id;
}
else
{
groups.push(gr.group);
x='sys_idIN' + groups.toString();
}
return x;
},
type: 'getgroupcontext'
});&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 Apr 2020 12:30:48 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/get-the-count-of-records-in-a-reference-variable/m-p/1397435#M54361</guid>
      <dc:creator>Jaspal Singh</dc:creator>
      <dc:date>2020-04-28T12:30:48Z</dc:date>
    </item>
    <item>
      <title>Re: Get the count of records in a reference variable</title>
      <link>https://www.servicenow.com/community/developer-forum/get-the-count-of-records-in-a-reference-variable/m-p/1397436#M54362</link>
      <description>&lt;P&gt;Hello Jaspal,&lt;/P&gt;
&lt;P&gt;The below script with logs,giving the count as 2(which is expected),but while returning the groups sys_id it is giving only one sys_id instead of 2.Any idea?Attached log for reference.&lt;/P&gt;
&lt;P&gt;If I have a rowcount of 1,I need to set the single group in the group variable by using client script(glideajax),how to achieve this?&lt;/P&gt;
&lt;P&gt;var getgroupcontexttest = Class.create();&lt;BR /&gt;getgroupcontexttest.prototype = Object.extendsObject(AbstractAjaxProcessor, {&lt;BR /&gt;getgrpcontexttestf : function(role)&lt;BR /&gt;{&lt;/P&gt;
&lt;P&gt;//var role = this.getParameter('sysparm_query');&lt;BR /&gt;var countis='';&lt;BR /&gt;var x=[];&lt;BR /&gt;var groups = [];&lt;BR /&gt;var gr = new GlideRecord('sys_group_has_role');&lt;BR /&gt;gr.addQuery('role.name',role);&lt;BR /&gt;gr.query();&lt;/P&gt;
&lt;P&gt;while(gr.next())&lt;BR /&gt;{&lt;BR /&gt;gs.log("@362363"+gr.group+"NOWROLE"+gr.role.name);&lt;BR /&gt;countis=gr.getRowCount();&lt;BR /&gt; gs.log("@362363 the COUNT is " + countis);&lt;BR /&gt;if(countis==1)&lt;BR /&gt;{&lt;BR /&gt;gs.log("@362363 the COUNT is only one "); &lt;BR /&gt;x=gr.group.sys_id;&lt;BR /&gt; //x='sys_idIN' + gr.group.sys_id;&lt;BR /&gt; gs.log("@362363 the value of X is " + x);&lt;BR /&gt;}&lt;BR /&gt;else&lt;BR /&gt;{&lt;BR /&gt; gs.log("@362363 the COUNT is more than one ");&lt;BR /&gt;groups.push(gr.group);&lt;BR /&gt;x='sys_idIN' + groups.toString();&lt;BR /&gt;}&lt;BR /&gt; gs.log("@362363 the last return of X is " + x);&lt;BR /&gt;return x;&lt;BR /&gt; &lt;BR /&gt;}&lt;BR /&gt;},&lt;BR /&gt; type: 'getgroupcontexttest'&lt;BR /&gt;});&lt;/P&gt;</description>
      <pubDate>Wed, 29 Apr 2020 07:55:04 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/get-the-count-of-records-in-a-reference-variable/m-p/1397436#M54362</guid>
      <dc:creator>Kumar60</dc:creator>
      <dc:date>2020-04-29T07:55:04Z</dc:date>
    </item>
    <item>
      <title>Re: Get the count of records in a reference variable</title>
      <link>https://www.servicenow.com/community/developer-forum/get-the-count-of-records-in-a-reference-variable/m-p/1397437#M54363</link>
      <description>&lt;P&gt;Can you replace else part with below in code above.&lt;/P&gt;
&lt;PRE class="language-markup"&gt;&lt;CODE&gt;else
{
x=groups.push(gr.group.sys_id);
}&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For populating it on the field with the value you need to write a client scirpt that would set it. Look for &lt;A href="https://community.servicenow.com/community?id=community_question&amp;amp;sys_id=a1afdfc0db2014104819fb24399619c8" target="_blank" rel="noopener noreferrer nofollow"&gt;link&lt;/A&gt; for a check.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Apr 2020 08:15:36 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/get-the-count-of-records-in-a-reference-variable/m-p/1397437#M54363</guid>
      <dc:creator>Jaspal Singh</dc:creator>
      <dc:date>2020-04-29T08:15:36Z</dc:date>
    </item>
    <item>
      <title>Re: Get the count of records in a reference variable</title>
      <link>https://www.servicenow.com/community/developer-forum/get-the-count-of-records-in-a-reference-variable/m-p/1397438#M54364</link>
      <description>&lt;P&gt;Hi Jaspal,&lt;/P&gt;
&lt;P&gt;I tried with multiple ways,but it seems not working.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Apr 2020 11:31:31 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/get-the-count-of-records-in-a-reference-variable/m-p/1397438#M54364</guid>
      <dc:creator>Kumar60</dc:creator>
      <dc:date>2020-04-29T11:31:31Z</dc:date>
    </item>
    <item>
      <title>Re: Get the count of records in a reference variable</title>
      <link>https://www.servicenow.com/community/developer-forum/get-the-count-of-records-in-a-reference-variable/m-p/1397439#M54365</link>
      <description>&lt;P&gt;Hi Kumar,&lt;/P&gt;
&lt;P&gt;you cannot set value to group variable if script include returns 1 value; reference qualifier will help in restricting the records and not setting the value&lt;/P&gt;
&lt;P&gt;you can use this approach:&lt;/P&gt;
&lt;P&gt;1) use onChange client script and use GlideAjax and check if only 1 group exist with that role; if yes then return that and set the value; if more than 1 return sys_ids&lt;/P&gt;
&lt;P&gt;Same function you can use for both the purpose; one from ref qualifier and one from GlideAjax&lt;/P&gt;
&lt;P&gt;2) keep the reference qualifier as it is -&amp;gt; this will help users to see restricted groups if more than 1&lt;/P&gt;
&lt;P&gt;Note: I assume the role2 variable is a string variable&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Client Script: onchange client script on role variable&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE class="language-markup"&gt;&lt;CODE&gt;function onChange(control, oldValue, newValue, isLoading) {
	if (isLoading) {
		return;
	}

if(newValue == ''){
g_form.clearValue('group_variable');
return;
}

	var ga = new GlideAjax('u_userInfoAjax');
	ga.addParam('sysparm_name', "getGroups");
	ga.addParam('sysparm_role', newValue);
	ga.getXMLAnswer(function(answer){
	
        if(answer != ''){
        g_form.setValue('group_variable', answer);	
        }

	});

}&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;Script Include:&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;var getgroupcontext = Class.create();
getgroupcontext.prototype = Object.extendsObject(AbstractAjaxProcessor, {

getgrpcontext : function(role)
{

var role = JSUtil.nil(role) ? this.getParameter('sysparm_role') : role;

var groups = [];
var gr = new GlideRecord('sys_group_has_role');
gr.addQuery('role.name',role);
gr.query();

if(gr.getRowCount() == 1)
return gr.getValue('group');

else{
while(gr.next())
{
groups.push(gr.getValue('group'));
}
return 'sys_idIN' + groups.toString();
}
},


type: 'getgroupcontext'
});&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Mark &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; Correct if this solves your issue and also mark &lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt; Helpful if you find my response worthy based on the impact.&lt;BR /&gt;Thanks&lt;BR /&gt;Ankur&lt;/P&gt;</description>
      <pubDate>Wed, 29 Apr 2020 11:53:29 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/get-the-count-of-records-in-a-reference-variable/m-p/1397439#M54365</guid>
      <dc:creator>Ankur Bawiskar</dc:creator>
      <dc:date>2020-04-29T11:53:29Z</dc:date>
    </item>
    <item>
      <title>Re: Get the count of records in a reference variable</title>
      <link>https://www.servicenow.com/community/developer-forum/get-the-count-of-records-in-a-reference-variable/m-p/1397440#M54366</link>
      <description>&lt;P&gt;Hello Ankur,&lt;/P&gt;
&lt;P&gt;If the count is 1,still the value is not getting set.I checked with logs,the answer value we are getting in client script is only 'sys_idIN'.&lt;BR /&gt;If the count is more than 1,scenario is working fine.&lt;/P&gt;
&lt;P&gt;I tried in background script,I am getting the single groups sys_id,if the count is one.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Apr 2020 04:24:34 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/get-the-count-of-records-in-a-reference-variable/m-p/1397440#M54366</guid>
      <dc:creator>Kumar60</dc:creator>
      <dc:date>2020-04-30T04:24:34Z</dc:date>
    </item>
    <item>
      <title>Re: Get the count of records in a reference variable</title>
      <link>https://www.servicenow.com/community/developer-forum/get-the-count-of-records-in-a-reference-variable/m-p/1397441#M54367</link>
      <description>&lt;P&gt;Hi Kumar,&lt;/P&gt;
&lt;P&gt;can you share your script include?&lt;/P&gt;
&lt;P&gt;when onchange is working what you are getting in answer variable?&lt;/P&gt;
&lt;P&gt;Did you print that?&lt;/P&gt;
&lt;P&gt;Regards&lt;BR /&gt;Ankur&lt;/P&gt;</description>
      <pubDate>Thu, 30 Apr 2020 04:38:10 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/get-the-count-of-records-in-a-reference-variable/m-p/1397441#M54367</guid>
      <dc:creator>Ankur Bawiskar</dc:creator>
      <dc:date>2020-04-30T04:38:10Z</dc:date>
    </item>
    <item>
      <title>Re: Get the count of records in a reference variable</title>
      <link>https://www.servicenow.com/community/developer-forum/get-the-count-of-records-in-a-reference-variable/m-p/1397442#M54368</link>
      <description>&lt;P&gt;My script include is below.When printing answer in client script only 'sys_idIN' is printing.&lt;/P&gt;
&lt;P&gt;var getgroupcontexttest2 = Class.create();&lt;BR /&gt;getgroupcontexttest2.prototype = Object.extendsObject(AbstractAjaxProcessor, {&lt;BR /&gt;getgrpcontext : function(role1)&lt;BR /&gt;{&lt;/P&gt;
&lt;P&gt;var role = JSUtil.nil(role1) ? this.getParameter('sysparm_role') : role1;&lt;/P&gt;
&lt;P&gt;var groups = [];&lt;BR /&gt;var gr = new GlideRecord('sys_group_has_role');&lt;BR /&gt;gr.addQuery('role.name',role1);&lt;BR /&gt;gr.query();&lt;/P&gt;
&lt;P&gt;if(gr.getRowCount() == 1){&lt;BR /&gt;return gr.getValue('group');&lt;BR /&gt; //return gr.group.sys_id;&lt;/P&gt;
&lt;P&gt;//return gr.group.getDisplayValue();&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;else{&lt;BR /&gt;while(gr.next())&lt;BR /&gt;{&lt;BR /&gt;groups.push(gr.getValue('group'));&lt;BR /&gt;}&lt;BR /&gt;return 'sys_idIN' + groups.toString();&lt;BR /&gt;}&lt;BR /&gt;},&lt;/P&gt;
&lt;P&gt;type: 'getgroupcontexttest2'&lt;BR /&gt;});&lt;/P&gt;
&lt;P&gt;Client script as follows:&lt;/P&gt;
&lt;P&gt;function onChange(control, oldValue, newValue, isLoading) {&lt;BR /&gt; if (isLoading || newValue == '') {&lt;BR /&gt; return;&lt;BR /&gt; }&lt;BR /&gt;if(newValue == ''){&lt;BR /&gt;g_form.clearValue('group2');&lt;BR /&gt;return;&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;var ga = new GlideAjax('getgroupcontexttest2');&lt;BR /&gt; ga.addParam('sysparm_name', "getgrpcontext");&lt;BR /&gt; ga.addParam('sysparm_role', newValue);&lt;BR /&gt; //ga.getXMLAnswer(function(answer){This is also trowing the same output.just tried splitting the getXMLAnswer as below.&lt;BR /&gt; ga.getXML(GetDetails);&lt;BR /&gt; function GetDetails(response) {&lt;BR /&gt; var answer = response.responseXML.documentElement.getAttribute("answer");&lt;BR /&gt; alert("@362363 answer from Script include is " + answer);&lt;BR /&gt;if(answer != ''){&lt;BR /&gt;//if(answer){This returns the same result&lt;BR /&gt; g_form.setValue('group2', answer);&lt;/P&gt;
&lt;P&gt;//g_form.setReadOnly('group2',true);&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt;//});&lt;BR /&gt; //Type appropriate comment here, and begin script below&lt;BR /&gt; &lt;BR /&gt;}&lt;/P&gt;</description>
      <pubDate>Thu, 30 Apr 2020 05:18:41 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/get-the-count-of-records-in-a-reference-variable/m-p/1397442#M54368</guid>
      <dc:creator>Kumar60</dc:creator>
      <dc:date>2020-04-30T05:18:41Z</dc:date>
    </item>
    <item>
      <title>Re: Get the count of records in a reference variable</title>
      <link>https://www.servicenow.com/community/developer-forum/get-the-count-of-records-in-a-reference-variable/m-p/1397443#M54369</link>
      <description>&lt;P&gt;Hi Kumar,&lt;/P&gt;
&lt;P&gt;please update script as below; you are storing role in this variable so use that&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="ng-scope"&gt;gr.addQuery('role.name',&lt;STRONG&gt;role&lt;/STRONG&gt;);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Mark &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; Correct if this solves your issue and also mark &lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt; Helpful if you find my response worthy based on the impact.&lt;BR /&gt;Thanks&lt;BR /&gt;Ankur&lt;/P&gt;</description>
      <pubDate>Thu, 30 Apr 2020 05:57:36 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/get-the-count-of-records-in-a-reference-variable/m-p/1397443#M54369</guid>
      <dc:creator>Ankur Bawiskar</dc:creator>
      <dc:date>2020-04-30T05:57:36Z</dc:date>
    </item>
    <item>
      <title>Re: Get the count of records in a reference variable</title>
      <link>https://www.servicenow.com/community/developer-forum/get-the-count-of-records-in-a-reference-variable/m-p/1397444#M54370</link>
      <description>&lt;P&gt;I tried doing that by updating gr.addQuery('role.name',&lt;STRONG&gt;role&lt;/STRONG&gt;);&lt;/P&gt;
&lt;P&gt;Now,If the count is two i.e more than one,the alert answer in client script is giving 2 sys_id's.&lt;/P&gt;
&lt;P&gt;But if the count is one then the alert for answer is throwing null.&lt;/P&gt;
&lt;P&gt;Tried by updating the while loop as below,in this case it's setting the group value if the count is one.&lt;/P&gt;
&lt;P&gt;But if the count is 2,then only one sys_id its giving in the alert.&lt;/P&gt;
&lt;P&gt;So as per my understanding,what ever the return is there after while(gr.next()) that is only giving the accurate result!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Apr 2020 06:37:50 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/get-the-count-of-records-in-a-reference-variable/m-p/1397444#M54370</guid>
      <dc:creator>Kumar60</dc:creator>
      <dc:date>2020-04-30T06:37:50Z</dc:date>
    </item>
    <item>
      <title>Re: Get the count of records in a reference variable</title>
      <link>https://www.servicenow.com/community/developer-forum/get-the-count-of-records-in-a-reference-variable/m-p/1397445#M54371</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;got your point;&lt;/P&gt;
&lt;P&gt;1) in case when there are more than 1 it is returning the group sys_id and setting&lt;/P&gt;
&lt;P&gt;2) but when more than 1 it is entering while and forming the array and returning something like this 'sys_idINsys_id1,sys_id2'&lt;/P&gt;
&lt;P&gt;so what you can check is whether the answer variable contains a string with 32 characters it means it is single sys_id&lt;/P&gt;
&lt;P&gt;when there are more than 1 records it would be a string with length more than 32&lt;/P&gt;
&lt;PRE class="language-markup"&gt;&lt;CODE&gt;var ga = new GlideAjax('u_userInfoAjax');
	ga.addParam('sysparm_name', "getGroups");
	ga.addParam('sysparm_role', newValue);
	ga.getXMLAnswer(function(answer){
	
        if(answer != '' &amp;amp;&amp;amp; answer.toString().length == 32){
        g_form.setValue('group_variable', answer);	
        }

	});&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Mark &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; Correct if this solves your issue and also mark &lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt; Helpful if you find my response worthy based on the impact.&lt;BR /&gt;Thanks&lt;BR /&gt;Ankur&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Apr 2020 12:59:10 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/get-the-count-of-records-in-a-reference-variable/m-p/1397445#M54371</guid>
      <dc:creator>Ankur Bawiskar</dc:creator>
      <dc:date>2020-04-30T12:59:10Z</dc:date>
    </item>
    <item>
      <title>Re: Get the count of records in a reference variable</title>
      <link>https://www.servicenow.com/community/developer-forum/get-the-count-of-records-in-a-reference-variable/m-p/1397446#M54372</link>
      <description>&lt;P&gt;Hi Kumar,&lt;/P&gt;
&lt;P&gt;Let me know if that answered your question.&lt;/P&gt;
&lt;P&gt;If so, please mark my response as &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; correct &amp;amp; &lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt; helpful so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.&lt;/P&gt;
&lt;P&gt;Regards&lt;BR /&gt;Ankur&lt;/P&gt;</description>
      <pubDate>Mon, 04 May 2020 03:56:28 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/get-the-count-of-records-in-a-reference-variable/m-p/1397446#M54372</guid>
      <dc:creator>Ankur Bawiskar</dc:creator>
      <dc:date>2020-05-04T03:56:28Z</dc:date>
    </item>
    <item>
      <title>Re: Get the count of records in a reference variable</title>
      <link>https://www.servicenow.com/community/developer-forum/get-the-count-of-records-in-a-reference-variable/m-p/1397447#M54373</link>
      <description>&lt;P&gt;Hello Ankur,&lt;/P&gt;
&lt;P&gt;A small change in the code returning the expected results.&lt;/P&gt;
&lt;P&gt;below is the modified line code:&lt;/P&gt;
&lt;P&gt;*****Code change in Script Include*****&lt;/P&gt;
&lt;P class="ng-scope"&gt;gr.query();&lt;/P&gt;
&lt;P class="ng-scope"&gt;if(gr.next()){//wrap in if,will fix the issue&lt;/P&gt;
&lt;P class="ng-scope"&gt;if(gr.getRowCount() == 1){&lt;BR /&gt;return gr.getValue('group');&lt;BR /&gt;//return gr.group.sys_id;&lt;/P&gt;
&lt;P class="ng-scope"&gt;//return gr.group.getDisplayValue();&lt;BR /&gt;}&lt;/P&gt;
&lt;P class="ng-scope"&gt;}//If condition close&lt;/P&gt;
&lt;P class="ng-scope"&gt;******Code change in Script Include******&lt;/P&gt;</description>
      <pubDate>Mon, 04 May 2020 12:07:49 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/get-the-count-of-records-in-a-reference-variable/m-p/1397447#M54373</guid>
      <dc:creator>Kumar60</dc:creator>
      <dc:date>2020-05-04T12:07:49Z</dc:date>
    </item>
  </channel>
</rss>

