<?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: How do I pull the parent.sys_class_name in a query? in Developer forum</title>
    <link>https://www.servicenow.com/community/developer-forum/how-do-i-pull-the-parent-sys-class-name-in-a-query/m-p/1901437#M558363</link>
    <description>&lt;P&gt;I have tried it and it works &lt;SPAN __jive_emoticon_name="happy" __jive_macro_name="emoticon" class="jive_emote jive_macro" data-renderedposition="7.997685432434082_170.53240966796875_16_16" src="https://www.servicenow.com/8.0.4.21bdc7e/images/emoticons/happy.png"&gt;&lt;/SPAN&gt;. &lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Hope it helps!&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Berny&lt;/P&gt;&lt;BR /&gt;</description>
    <pubDate>Tue, 08 Nov 2016 06:38:50 GMT</pubDate>
    <dc:creator>bernyalvarado</dc:creator>
    <dc:date>2016-11-08T06:38:50Z</dc:date>
    <item>
      <title>How do I pull the parent.sys_class_name in a query?</title>
      <link>https://www.servicenow.com/community/developer-forum/how-do-i-pull-the-parent-sys-class-name-in-a-query/m-p/1901435#M558361</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to get a count of the parent.sys_class_name in the cmdb_rel_ci table but I do not understand why the script is not working. &amp;nbsp; I used this script previously to just pull sys_class_name from a different table and it had worked so I am not sure why parent.sys_class_name is not working.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="javascript" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14785426880382204" data-renderedposition="176_8_1192_464" jivemacro_uid="_14785426880382204"&gt;&lt;P&gt;//count number of server instances grouped by sys class name&lt;/P&gt;&lt;P&gt;var agg = new GlideAggregate('cmdb_rel_ci');&lt;/P&gt;&lt;P&gt;agg.addAggregate('COUNT', 'parent.sys_class_name');&lt;/P&gt;&lt;P&gt;agg.groupBy('parent.sys_class_name');&lt;/P&gt;&lt;P&gt;agg.query();&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;while (agg.next()) {&lt;/P&gt;&lt;P&gt; &amp;nbsp; var serverType = agg.parent.sys_class_name.getDisplayValue();&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &amp;nbsp; var hierarchy = new GlideRecord('u_land_o_lakes_physical_servers_allocation');&lt;/P&gt;&lt;P&gt; &amp;nbsp; hierarchy.addQuery('u_allocate_to',serverType);&lt;/P&gt;&lt;P&gt; &amp;nbsp; hierarchy.query();&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &amp;nbsp; var getCount = agg.getAggregate('COUNT', 'parent.sys_class_name');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &amp;nbsp; if (hierarchy.next()) {&lt;/P&gt;&lt;P&gt; &amp;nbsp; hierarchy.u_allocate_to = serverType;&lt;/P&gt;&lt;P&gt; &amp;nbsp; hierarchy.update();&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &amp;nbsp; } else {&lt;/P&gt;&lt;P&gt; &amp;nbsp; hierarchy.u_allocate_to = serverType;&lt;/P&gt;&lt;P&gt; &amp;nbsp; hierarchy.insert();&lt;/P&gt;&lt;P&gt; &amp;nbsp; }&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 07 Nov 2016 18:19:28 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-do-i-pull-the-parent-sys-class-name-in-a-query/m-p/1901435#M558361</guid>
      <dc:creator>zsquared</dc:creator>
      <dc:date>2016-11-07T18:19:28Z</dc:date>
    </item>
    <item>
      <title>Re: How do I pull the parent.sys_class_name in a query?</title>
      <link>https://www.servicenow.com/community/developer-forum/how-do-i-pull-the-parent-sys-class-name-in-a-query/m-p/1901436#M558362</link>
      <description>&lt;P&gt;Hi Zhen,&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;On line 9, try the following instead: &lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;PRE __jive_macro_name="quote" class="jive_macro_quote jive_text_macro" data-renderedposition="100.94908142089844_7.997685432434082_1042_41"&gt;&lt;P&gt;var serverType = agg.getValue('parent.sys_class_name');&lt;/P&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Berny&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 08 Nov 2016 06:38:21 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-do-i-pull-the-parent-sys-class-name-in-a-query/m-p/1901436#M558362</guid>
      <dc:creator>bernyalvarado</dc:creator>
      <dc:date>2016-11-08T06:38:21Z</dc:date>
    </item>
    <item>
      <title>Re: How do I pull the parent.sys_class_name in a query?</title>
      <link>https://www.servicenow.com/community/developer-forum/how-do-i-pull-the-parent-sys-class-name-in-a-query/m-p/1901437#M558363</link>
      <description>&lt;P&gt;I have tried it and it works &lt;SPAN __jive_emoticon_name="happy" __jive_macro_name="emoticon" class="jive_emote jive_macro" data-renderedposition="7.997685432434082_170.53240966796875_16_16" src="https://www.servicenow.com/8.0.4.21bdc7e/images/emoticons/happy.png"&gt;&lt;/SPAN&gt;. &lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Hope it helps!&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Berny&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 08 Nov 2016 06:38:50 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-do-i-pull-the-parent-sys-class-name-in-a-query/m-p/1901437#M558363</guid>
      <dc:creator>bernyalvarado</dc:creator>
      <dc:date>2016-11-08T06:38:50Z</dc:date>
    </item>
    <item>
      <title>Re: How do I pull the parent.sys_class_name in a query?</title>
      <link>https://www.servicenow.com/community/developer-forum/how-do-i-pull-the-parent-sys-class-name-in-a-query/m-p/1901438#M558364</link>
      <description>&lt;P&gt;Thank you! I also realized it was an error in my syntax!&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 08 Nov 2016 16:21:14 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-do-i-pull-the-parent-sys-class-name-in-a-query/m-p/1901438#M558364</guid>
      <dc:creator>zsquared</dc:creator>
      <dc:date>2016-11-08T16:21:14Z</dc:date>
    </item>
  </channel>
</rss>

