<?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>post GlideRecord utility class in Developer articles</title>
    <link>https://www.servicenow.com/community/developer-articles/gliderecord-utility-class/ta-p/2480002</link>
    <description>&lt;DIV class="lia-message-template-content-zone"&gt;
&lt;P&gt;&lt;FONT face="andale mono,times"&gt;&lt;SPAN&gt;In OOB, we have a useful utility, &lt;STRONG&gt;GlideRecordUtil() &lt;/STRONG&gt;script include&lt;STRONG style="color: #252525;"&gt;&amp;nbsp;&lt;/STRONG&gt;to work with GlideRecords. I've found two handy functions to fetch and update the record data.&lt;/SPAN&gt; &lt;/FONT&gt;&lt;/P&gt;
&lt;DIV&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;FONT face="andale mono,times"&gt;&lt;SPAN&gt;populateFromGR()&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT face="andale mono,times"&gt;mergeToGR()&lt;/FONT&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;FONT face="andale mono,times"&gt;&lt;U&gt;&lt;STRONG&gt;populateFromGR(object, gr, ignoreFields)&amp;nbsp;&lt;/STRONG&gt;&lt;/U&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;FONT face="andale mono,times"&gt;This function can be used to get the full record data&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT face="andale mono,times"&gt;The data will be retrieved in an Object response&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT face="andale mono,times"&gt;&lt;STRONG&gt;Object&lt;/STRONG&gt; : Pass the object variable to store the data, &lt;STRONG&gt;gr&lt;/STRONG&gt; - Pass the GlideRecord instance, &lt;STRONG&gt;ignoreFields&lt;/STRONG&gt; - An optional object parameter that can exclude fields in the final response.&lt;/FONT&gt;&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&lt;FONT face="andale mono,times"&gt;&lt;STRONG&gt;&lt;U&gt;Sample script&lt;/U&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;var responseObject = {}; //hashmap object variable to store final response
var getData = new GlideRecordUtil().getGR("change_request", "c83c5e5347c12200e0ef563dbb9a7190"); //pass the table name and Record sys_id to get the GlideRecord instance
var ignoreFields = {"sys_created_on": true, "sys_updated_by": true}; //Pass the fields that you want to exclude in the final response
new GlideRecordUtil().populateFromGR(responseObject, getData, ignoreFields); //The main function to retrieve the data
gs.print(JSON.stringify(responseObject, null, 4)); //Decode the object&lt;/LI-CODE&gt;
&lt;P&gt;&lt;FONT face="andale mono,times"&gt;&lt;U&gt;&lt;STRONG&gt;Output&lt;/STRONG&gt;&lt;/U&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SaiKumarB_0-1676529856364.png" style="width: 400px;"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/240865i26716715E9B7284C/image-size/medium?v=v2&amp;amp;px=400" srcset="/community/image/serverpage/image-id/240865i26716715E9B7284C/image-size/medium?v=v2&amp;amp;px=400 1.0x, /community/image/serverpage/image-id/240865i26716715E9B7284C/image-dimensions/581x800?v=v2 2.0x" role="button" title="SaiKumarB_0-1676529856364.png" alt="SaiKumarB_0-1676529856364.png" /&gt;&lt;/span&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="andale mono,times"&gt;&lt;U&gt;&lt;STRONG&gt;mergeToGR(object, gr, ignoreFields)&lt;/STRONG&gt;&lt;/U&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;FONT face="andale mono,times"&gt;This function can be used to update the record data&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT face="andale mono,times"&gt;&lt;STRONG&gt;object&amp;nbsp;&lt;/STRONG&gt;- Pass the field names and values, &lt;STRONG&gt;gr&amp;nbsp;&lt;/STRONG&gt;-&amp;nbsp;Pass the GlideRecord instance, &lt;STRONG&gt;ignoreFields&lt;/STRONG&gt; - An optional object parameter to ignore the fields.&lt;/FONT&gt;&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&lt;FONT face="andale mono,times"&gt;&lt;STRONG&gt;&lt;U&gt;Sample script&lt;/U&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;var updateObject = {"category" : "Hardware"}; //Pass the field name and values
var updateData = new GlideRecordUtil().getGR("change_request", "c83c5e5347c12200e0ef563dbb9a7190"); //Get the GlideRecord instance
var ignoreFields = {"sys_created_on": true}; //These fields will not be updated
new GlideRecordUtil().mergeToGR(updateObject , updateData, ignoreFields); //The main function picks the object as Input
updateData.update(); //Update the record using GlideRecord instance&lt;/LI-CODE&gt;
&lt;DIV&gt;
&lt;DIV class="lia-align-left"&gt;&lt;FONT face="andale mono,times"&gt;&lt;U&gt;&lt;STRONG&gt;Output&lt;/STRONG&gt;&lt;/U&gt;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV class="lia-align-left"&gt;&lt;U&gt;&lt;/U&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SaiKumarB_1-1676530550020.png" style="width: 400px;"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/240866i5A23A41CECEEED0B/image-size/medium?v=v2&amp;amp;px=400" srcset="/community/image/serverpage/image-id/240866i5A23A41CECEEED0B/image-size/medium?v=v2&amp;amp;px=400 1.0x" role="button" title="SaiKumarB_1-1676530550020.png" alt="SaiKumarB_1-1676530550020.png" /&gt;&lt;/span&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="andale mono,times"&gt;I hope you like my article&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="andale mono,times"&gt;Kindly, Post comments if you have any queries&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;Thanks,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;Sai Kumar B&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;Community Rising Star 2023 &amp;amp; 2022&lt;/FONT&gt;&lt;/P&gt;
&lt;/DIV&gt;
&lt;DIV class="lia-align-right"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 16 Feb 2023 07:22:28 GMT</pubDate>
    <dc:creator>Sai Kumar B</dc:creator>
    <dc:date>2023-02-16T07:22:28Z</dc:date>
    <item>
      <title>GlideRecord utility class</title>
      <link>https://www.servicenow.com/community/developer-articles/gliderecord-utility-class/ta-p/2480002</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Mighty GlideRecordUtil()&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2023 07:22:28 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-articles/gliderecord-utility-class/ta-p/2480002</guid>
      <dc:creator>Sai Kumar B</dc:creator>
      <dc:date>2023-02-16T07:22:28Z</dc:date>
    </item>
    <item>
      <title>Re: GlideRecord utility class</title>
      <link>https://www.servicenow.com/community/developer-articles/gliderecord-utility-class/tac-p/2480088#M7033</link>
      <description>&lt;P&gt;Good one. I can think of a possible usage of the seconde message:&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;var incidentGR = new GlideRecord('incident');
incidentGR.addEncodedQuery('state=1^caller_id=77ad8176731313005754660c4cf6a7de'); //David Miller

var updateData = {"caller_id": "6816f79cc0a8016401c5a33be04be441"}; //Martin Ivanov

new GlideRecordUtil().mergeToGR(updateData , incidentGR);

incidentGR.updateMultiple();&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 16 Feb 2023 08:35:37 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-articles/gliderecord-utility-class/tac-p/2480088#M7033</guid>
      <dc:creator>Martin Ivanov</dc:creator>
      <dc:date>2023-02-16T08:35:37Z</dc:date>
    </item>
    <item>
      <title>Re: GlideRecord utility class</title>
      <link>https://www.servicenow.com/community/developer-articles/gliderecord-utility-class/tac-p/2480628#M7036</link>
      <description>&lt;P&gt;Nice.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;More use cases identified here:&amp;nbsp;&lt;A href="https://docs.servicenow.com/bundle/tokyo-application-development/page/script/server-scripting/concept/c_ScriptIncludes.html#usingDiscoveryScriptIncludes" target="_self"&gt;https://docs.servicenow.com/bundle/tokyo-application-development/page/script/server-scripting/concept/c_ScriptIncludes.html#usingDiscoveryScriptIncludes&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2023 15:26:13 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-articles/gliderecord-utility-class/tac-p/2480628#M7036</guid>
      <dc:creator>Allen Andreas</dc:creator>
      <dc:date>2023-02-16T15:26:13Z</dc:date>
    </item>
    <item>
      <title>Re: GlideRecord utility class</title>
      <link>https://www.servicenow.com/community/developer-articles/gliderecord-utility-class/tac-p/2482275#M7048</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/305072"&gt;@Martin Ivanov&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Thank you for reading my article and providing the solution that can help community users.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 18 Feb 2023 08:31:50 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-articles/gliderecord-utility-class/tac-p/2482275#M7048</guid>
      <dc:creator>Sai Kumar B</dc:creator>
      <dc:date>2023-02-18T08:31:50Z</dc:date>
    </item>
    <item>
      <title>Re: GlideRecord utility class</title>
      <link>https://www.servicenow.com/community/developer-articles/gliderecord-utility-class/tac-p/2482276#M7049</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/221263"&gt;@Allen Andreas&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Thank you for reading my article and providing reference to additional use cases.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 18 Feb 2023 08:33:08 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-articles/gliderecord-utility-class/tac-p/2482276#M7049</guid>
      <dc:creator>Sai Kumar B</dc:creator>
      <dc:date>2023-02-18T08:33:08Z</dc:date>
    </item>
  </channel>
</rss>

