<?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 to update Read only Custom field to Null for 100 of records in alm_hardware Table in Fix scr in Developer forum</title>
    <link>https://www.servicenow.com/community/developer-forum/how-to-update-read-only-custom-field-to-null-for-100-of-records/m-p/2876953#M1098534</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/345834"&gt;@VIKAS45&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can use background script or fix script.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var gr_hardware = new GlideRecord("alm_hardware");
gr_hardware.addEncodedQuery(""); // Add your encoded query here which filters your required records
gr_hardware.query();

while (gr_hardware.next())
{
    gr_hardware.autoSysFields(false); // this will prevent updating updated by and updated field, use if required.
    gr_hardware.setWorkflow(false); // skip business rules
    gr_hardware.setValue(customFieldName, ''); // Set the field value to null
    gr_hardware.update(); 
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Note:&amp;nbsp;Please Mark this&amp;nbsp;Helpful&amp;nbsp;and&amp;nbsp;Accepted Solution.&amp;nbsp;If this Helps you to understand. This will help both the community and me.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
    <pubDate>Tue, 26 Mar 2024 06:24:09 GMT</pubDate>
    <dc:creator>abhishekdalvi</dc:creator>
    <dc:date>2024-03-26T06:24:09Z</dc:date>
    <item>
      <title>How to update Read only Custom field to Null for 100 of records in alm_hardware Table in Fix script?</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-update-read-only-custom-field-to-null-for-100-of-records/m-p/2876909#M1098519</link>
      <description>&lt;P&gt;How to update Read only Custom field to Null for 100 of records in alm_hardware Table using Fix script or any other Method?&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2024 05:23:29 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-update-read-only-custom-field-to-null-for-100-of-records/m-p/2876909#M1098519</guid>
      <dc:creator>VIKAS45</dc:creator>
      <dc:date>2024-03-26T05:23:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to update Read only Custom field to Null for 100 of records in alm_hardware Table in Fix scr</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-update-read-only-custom-field-to-null-for-100-of-records/m-p/2876924#M1098526</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/345834"&gt;@VIKAS45&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Step 1: Navigate to Background Script&amp;nbsp; Scripts - Background&amp;nbsp;&lt;BR /&gt;&lt;STRONG&gt;Script:&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;    var tableName = 'alm_hardware'; 
    var customFieldName = 'u_custom_field'; // REPLACE with your field name
    var gr = new GlideRecord(tableName);
    gr.query(); // Execute the query to retrieve the records
    
    var count = 0;
    while (gr.next()) {
      gr.setValue(customFieldName, ''); // Set the field value to null (empty string in this context)
      gr.setWorkflow(false); // Optionally, skip business rules, if necessary
      gr.update(); // Update the record
      count++;
    }
    
    gs.info(count + ' records updated in ' + tableName);&lt;/LI-CODE&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Note:&amp;nbsp;Please Mark this&amp;nbsp;Helpful&amp;nbsp;and&amp;nbsp;Accepted Solution.&amp;nbsp;If this Helps you to understand. This will help both the community and me..&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;- Keep Learning ‌‌ &lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;Thanks &amp;amp; Regards&amp;nbsp;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;Deepak Sharma&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2024 05:41:09 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-update-read-only-custom-field-to-null-for-100-of-records/m-p/2876924#M1098526</guid>
      <dc:creator>Deepak Shaerma</dc:creator>
      <dc:date>2024-03-26T05:41:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to update Read only Custom field to Null for 100 of records in alm_hardware Table in Fix scr</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-update-read-only-custom-field-to-null-for-100-of-records/m-p/2876936#M1098528</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/345834"&gt;@VIKAS45&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can use either fix scripts or background scripts or you can even schedule it&amp;nbsp;&lt;/P&gt;&lt;P&gt;below is the sample code&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var almAsset= new GlideRecord("alm_hardware");
almAsset.query();
while (almAsset.next())
 {
almAsset.customFieldName= " "; 
almAsset.update(); 
 }&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 26 Mar 2024 06:02:53 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-update-read-only-custom-field-to-null-for-100-of-records/m-p/2876936#M1098528</guid>
      <dc:creator>Basheer</dc:creator>
      <dc:date>2024-03-26T06:02:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to update Read only Custom field to Null for 100 of records in alm_hardware Table in Fix scr</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-update-read-only-custom-field-to-null-for-100-of-records/m-p/2876937#M1098529</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/345834"&gt;@VIKAS45&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can use a background script or fix script.&lt;/P&gt;&lt;P&gt;please find the script below,&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;var&lt;/SPAN&gt;&lt;SPAN&gt; gr = &lt;/SPAN&gt;&lt;SPAN&gt;new&lt;/SPAN&gt; &lt;SPAN&gt;GlideRecord&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'alm_hardware'&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;//gr.addQuery('state','in use'); // write the query&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; gr.query();&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; gr.autoSysFields(&lt;/SPAN&gt;&lt;SPAN&gt;false&lt;/SPAN&gt;&lt;SPAN&gt;); &lt;/SPAN&gt;&lt;SPAN&gt;//// so that the records don't have system updates&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; gr.setLimit(&lt;/SPAN&gt;&lt;SPAN&gt;100&lt;/SPAN&gt;&lt;SPAN&gt;); // so it won't run for other records&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;while&lt;/SPAN&gt;&lt;SPAN&gt; (gr.next()) {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; gr.fieldname = &lt;/SPAN&gt;&lt;SPAN&gt;''&lt;/SPAN&gt;&lt;SPAN&gt;; &lt;/SPAN&gt;&lt;SPAN&gt;// Set the field value to null&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; gr.setWorkflow(&lt;/SPAN&gt;&lt;SPAN&gt;false&lt;/SPAN&gt;&lt;SPAN&gt;); &lt;/SPAN&gt;&lt;SPAN&gt;// Necessary if you are updating a bulk records&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; gr.update(); &lt;/SPAN&gt;&lt;SPAN&gt;// Update the record&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; }&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 26 Mar 2024 06:05:31 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-update-read-only-custom-field-to-null-for-100-of-records/m-p/2876937#M1098529</guid>
      <dc:creator>Deborah Brown L</dc:creator>
      <dc:date>2024-03-26T06:05:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to update Read only Custom field to Null for 100 of records in alm_hardware Table in Fix scr</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-update-read-only-custom-field-to-null-for-100-of-records/m-p/2876953#M1098534</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/345834"&gt;@VIKAS45&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can use background script or fix script.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var gr_hardware = new GlideRecord("alm_hardware");
gr_hardware.addEncodedQuery(""); // Add your encoded query here which filters your required records
gr_hardware.query();

while (gr_hardware.next())
{
    gr_hardware.autoSysFields(false); // this will prevent updating updated by and updated field, use if required.
    gr_hardware.setWorkflow(false); // skip business rules
    gr_hardware.setValue(customFieldName, ''); // Set the field value to null
    gr_hardware.update(); 
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Note:&amp;nbsp;Please Mark this&amp;nbsp;Helpful&amp;nbsp;and&amp;nbsp;Accepted Solution.&amp;nbsp;If this Helps you to understand. This will help both the community and me.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2024 06:24:09 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-update-read-only-custom-field-to-null-for-100-of-records/m-p/2876953#M1098534</guid>
      <dc:creator>abhishekdalvi</dc:creator>
      <dc:date>2024-03-26T06:24:09Z</dc:date>
    </item>
  </channel>
</rss>

