<?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: Script Help !! in Developer forum</title>
    <link>https://www.servicenow.com/community/developer-forum/script-help/m-p/3405408#M1233150</link>
    <description>&lt;P&gt;kb_knowledge is the table for knowledge articles not knowledge base.&lt;/P&gt;
&lt;P&gt;Try this script in After Delete Business rule on kb_knowledge table:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;    var att = new GlideRecord('sys_attachment');
    att.addEncodedQuery('table_sys_id=' + current.sys_id);
    att.query();
    att.deleteMultiple();
&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;STRONG style="color: black;"&gt;Please mark the answer correct/helpful accordingly.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 15 Oct 2025 07:50:43 GMT</pubDate>
    <dc:creator>Raghav Sharma24</dc:creator>
    <dc:date>2025-10-15T07:50:43Z</dc:date>
    <item>
      <title>Script Help !!</title>
      <link>https://www.servicenow.com/community/developer-forum/script-help/m-p/3405375#M1233135</link>
      <description>&lt;P&gt;Hi Team,&lt;/P&gt;&lt;P&gt;I have the below scenario to be implemented help here please.&lt;/P&gt;&lt;P&gt;When a record from the Knowledge Base (kb_knowledge) table is deleted, you want to delete all its attachments to save space.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Oct 2025 07:32:18 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/script-help/m-p/3405375#M1233135</guid>
      <dc:creator>vidishaagarwal5</dc:creator>
      <dc:date>2025-10-15T07:32:18Z</dc:date>
    </item>
    <item>
      <title>Re: Script Help !!</title>
      <link>https://www.servicenow.com/community/developer-forum/script-help/m-p/3405399#M1233145</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/677626"&gt;@vidishaagarwal5&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The Below Simple code will help you !!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;// Table: kb_knowledge&lt;BR /&gt;// When: before delete&lt;BR /&gt;(function executeRule(current, previous) {&lt;BR /&gt;var attachmentGR = new GlideRecord('sys_attachment');&lt;BR /&gt;attachmentGR.addQuery('table_name', 'kb_knowledge');&lt;BR /&gt;attachmentGR.addQuery('table_sys_id', current.sys_id);&lt;BR /&gt;attachmentGR.query();&lt;/P&gt;
&lt;P&gt;while (attachmentGR.next()) {&lt;BR /&gt;attachmentGR.deleteRecord();&lt;BR /&gt;}&lt;BR /&gt;})(current, previous);&lt;/P&gt;</description>
      <pubDate>Wed, 15 Oct 2025 07:44:23 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/script-help/m-p/3405399#M1233145</guid>
      <dc:creator>Ravi Gaurav</dc:creator>
      <dc:date>2025-10-15T07:44:23Z</dc:date>
    </item>
    <item>
      <title>Re: Script Help !!</title>
      <link>https://www.servicenow.com/community/developer-forum/script-help/m-p/3405400#M1233146</link>
      <description>&lt;P&gt;Let me try this one .. I will get back to you&lt;/P&gt;</description>
      <pubDate>Wed, 15 Oct 2025 07:46:14 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/script-help/m-p/3405400#M1233146</guid>
      <dc:creator>vidishaagarwal5</dc:creator>
      <dc:date>2025-10-15T07:46:14Z</dc:date>
    </item>
    <item>
      <title>Re: Script Help !!</title>
      <link>https://www.servicenow.com/community/developer-forum/script-help/m-p/3405408#M1233150</link>
      <description>&lt;P&gt;kb_knowledge is the table for knowledge articles not knowledge base.&lt;/P&gt;
&lt;P&gt;Try this script in After Delete Business rule on kb_knowledge table:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;    var att = new GlideRecord('sys_attachment');
    att.addEncodedQuery('table_sys_id=' + current.sys_id);
    att.query();
    att.deleteMultiple();
&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;STRONG style="color: black;"&gt;Please mark the answer correct/helpful accordingly.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Oct 2025 07:50:43 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/script-help/m-p/3405408#M1233150</guid>
      <dc:creator>Raghav Sharma24</dc:creator>
      <dc:date>2025-10-15T07:50:43Z</dc:date>
    </item>
    <item>
      <title>Re: Script Help !!</title>
      <link>https://www.servicenow.com/community/developer-forum/script-help/m-p/3405417#M1233152</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/677626"&gt;@vidishaagarwal5&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;1) on&amp;nbsp; you table you can create the after business rule (delete)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="TejasSN_LogicX_0-1760514865548.png" style="width: 400px;"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/476821i561E2832EC3271F2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="TejasSN_LogicX_0-1760514865548.png" alt="TejasSN_LogicX_0-1760514865548.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;and paste this script in your business rule&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;(function executeRule(current, previous /*null when async*/) {

    //thiss  Find all attachments linked to this Knowledge record
    var attachmentGR = new GlideRecord('sys_attachment');
    attachmentGR.addQuery('table_sys_id', current.sys_id);
    attachmentGR.addQuery('table_name', 'kb_knowledge');
    attachmentGR.query();

    //now  Delete each attachment
    while (attachmentGR.next()) {
        attachmentGR.deleteRecord();
    }

})(current, previous);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If my response/article helped you, please mark it as the correct answer and close the thread — this helps other readers in the community.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Regards&lt;/STRONG&gt;,&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Tejas&amp;nbsp;&lt;/STRONG&gt;&lt;BR /&gt;&lt;span class="lia-unicode-emoji" title=":rocket:"&gt;🚀&lt;/span&gt; ServiceNow Developer | &lt;span class="lia-unicode-emoji" title=":trophy:"&gt;🏆&lt;/span&gt; HackaNow Finalist | &lt;span class="lia-unicode-emoji" title=":light_bulb:"&gt;💡&lt;/span&gt; Community Contributor&lt;BR /&gt;&lt;span class="lia-unicode-emoji" title=":e_mail:"&gt;📧&lt;/span&gt; &lt;STRONG&gt;Email:&lt;/STRONG&gt; tejas.adhalrao11@gmail.com&lt;BR /&gt;&lt;span class="lia-unicode-emoji" title=":link:"&gt;🔗&lt;/span&gt; &lt;STRONG&gt;LinkedIn:&lt;/STRONG&gt; &lt;A class="" title="https://www.linkedin.com/in/tejas1018/" href="https://www.linkedin.com/in/tejas1018/" target="_blank" rel="noreferrer noopener"&gt;linkedin.com/in/tejas1018&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Oct 2025 07:55:44 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/script-help/m-p/3405417#M1233152</guid>
      <dc:creator>Tejas Adhalrao</dc:creator>
      <dc:date>2025-10-15T07:55:44Z</dc:date>
    </item>
    <item>
      <title>Re: Script Help !!</title>
      <link>https://www.servicenow.com/community/developer-forum/script-help/m-p/3405421#M1233153</link>
      <description>&lt;P&gt;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/677626"&gt;@vidishaagarwal5&lt;/a&gt;,Once you delete an article record, no attachment will appear in the sys_attachment table, so they are removed automatically from there but might still remain part of the system. Follow this thread to remove them permanently.&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.servicenow.com/community/developer-forum/finding-and-deleting-orphaned-attachments/m-p/2618342" target="_blank"&gt;https://www.servicenow.com/community/developer-forum/finding-and-deleting-orphaned-attachments/m-p/2618342&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Oct 2025 08:09:29 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/script-help/m-p/3405421#M1233153</guid>
      <dc:creator>miftikhar20</dc:creator>
      <dc:date>2025-10-15T08:09:29Z</dc:date>
    </item>
  </channel>
</rss>

