<?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 close the task when ritm is closed in ITSM forum</title>
    <link>https://www.servicenow.com/community/itsm-forum/close-the-task-when-ritm-is-closed/m-p/3175425#M535480</link>
    <description>&lt;P&gt;Hi , i have been trying to close the parent ritm when all the childs are closed.&amp;nbsp;&lt;/P&gt;&lt;P&gt;here is the before update BR with condition state changed to closed complete&lt;/P&gt;&lt;P&gt;var count=0;&lt;BR /&gt;var tasks = new GlideRecord('sc_task');&lt;BR /&gt;tasks.addQuery('request_item',current.request_item);&lt;BR /&gt;tasks.query();&lt;BR /&gt;var taskcount = tasks.getRowCount();&lt;BR /&gt;while(tasks.next())&lt;BR /&gt;{&lt;BR /&gt;if(tasks.state == 3)&lt;BR /&gt;{&lt;BR /&gt;count++&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;if(count == taskcount)&lt;BR /&gt;{&lt;BR /&gt;var rq = new GlideRecord('sc_req_item');&lt;BR /&gt;rq.addQuery('sys_id',current.request_item);&lt;BR /&gt;rq.query();&lt;BR /&gt;if(rq.next())&lt;BR /&gt;{&lt;BR /&gt;rq.state = 3;&lt;BR /&gt;rq.update();&lt;BR /&gt;}&lt;BR /&gt;}&amp;nbsp;&lt;/P&gt;&lt;P&gt;but its not working as expected as when state changed to WIP then its moving to close complete state in RITM&amp;nbsp;&lt;/P&gt;&lt;P&gt;do advise as what is wrong.&lt;/P&gt;</description>
    <pubDate>Wed, 12 Feb 2025 08:33:55 GMT</pubDate>
    <dc:creator>tushar_ghadage</dc:creator>
    <dc:date>2025-02-12T08:33:55Z</dc:date>
    <item>
      <title>close the task when ritm is closed</title>
      <link>https://www.servicenow.com/community/itsm-forum/close-the-task-when-ritm-is-closed/m-p/3175425#M535480</link>
      <description>&lt;P&gt;Hi , i have been trying to close the parent ritm when all the childs are closed.&amp;nbsp;&lt;/P&gt;&lt;P&gt;here is the before update BR with condition state changed to closed complete&lt;/P&gt;&lt;P&gt;var count=0;&lt;BR /&gt;var tasks = new GlideRecord('sc_task');&lt;BR /&gt;tasks.addQuery('request_item',current.request_item);&lt;BR /&gt;tasks.query();&lt;BR /&gt;var taskcount = tasks.getRowCount();&lt;BR /&gt;while(tasks.next())&lt;BR /&gt;{&lt;BR /&gt;if(tasks.state == 3)&lt;BR /&gt;{&lt;BR /&gt;count++&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;if(count == taskcount)&lt;BR /&gt;{&lt;BR /&gt;var rq = new GlideRecord('sc_req_item');&lt;BR /&gt;rq.addQuery('sys_id',current.request_item);&lt;BR /&gt;rq.query();&lt;BR /&gt;if(rq.next())&lt;BR /&gt;{&lt;BR /&gt;rq.state = 3;&lt;BR /&gt;rq.update();&lt;BR /&gt;}&lt;BR /&gt;}&amp;nbsp;&lt;/P&gt;&lt;P&gt;but its not working as expected as when state changed to WIP then its moving to close complete state in RITM&amp;nbsp;&lt;/P&gt;&lt;P&gt;do advise as what is wrong.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Feb 2025 08:33:55 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/close-the-task-when-ritm-is-closed/m-p/3175425#M535480</guid>
      <dc:creator>tushar_ghadage</dc:creator>
      <dc:date>2025-02-12T08:33:55Z</dc:date>
    </item>
    <item>
      <title>Re: close the task when ritm is closed</title>
      <link>https://www.servicenow.com/community/itsm-forum/close-the-task-when-ritm-is-closed/m-p/3175851#M535502</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/831651"&gt;@tushar_ghadage&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I am not wrong it is OOTB, when task get closed the RITM get close via flow only.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Feb 2025 13:03:15 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/close-the-task-when-ritm-is-closed/m-p/3175851#M535502</guid>
      <dc:creator>Dr Atul G- LNG</dc:creator>
      <dc:date>2025-02-12T13:03:15Z</dc:date>
    </item>
    <item>
      <title>Re: close the task when ritm is closed</title>
      <link>https://www.servicenow.com/community/itsm-forum/close-the-task-when-ritm-is-closed/m-p/3175913#M535512</link>
      <description>&lt;P&gt;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/831651"&gt;@tushar_ghadage&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;you can use business rule or flow designer for this&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;BR approach: I shared the script few years ago; check this&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://www.servicenow.com/community/developer-forum/how-can-we-close-ritm-when-all-the-catalog-task-is-closed-for/m-p/1845538/page/2" target="_blank"&gt;How can we close RITM when all the catalog task is closed for that item?&lt;/A&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;you can use after update BR on sc_task&lt;/P&gt;
&lt;P&gt;Condition: State [IS ONE OF] Closed Complete/Closed Incomplete AND Request Item.Item == Your Catalog Item&lt;/P&gt;
&lt;P&gt;Script:&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;(function executeRule(current, previous /*null when async*/) {


        // Add your code here

        var gr = new GlideRecord('sc_task');

        gr.addQuery('request_item', current.request_item);

        gr.addQuery('active', true);

        gr.query();

        if(!gr.next()){

               var ritm = current.request_item.getRefRecord();

               ritm.state = 3;

               ritm.update();

        }


})(current, previous);

&lt;/LI-CODE&gt;
&lt;P&gt;&lt;STRONG&gt;Flow Designer approach: I shared solution few years ago&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;I have shared solution below using flow designer to close parent INC when all child INCs are closed.&lt;/P&gt;
&lt;P&gt;Enhance it for sc_req_item and sc_task table&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.servicenow.com/community?id=community_question&amp;amp;sys_id=2200aa98db1a60d0f21f5583ca961915" target="_blank"&gt;If all child incident is closed then after Parent incident should be closed. How to achieve through....&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;If my response helped please mark it correct and close the thread so that it benefits future readers.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Feb 2025 13:38:13 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/close-the-task-when-ritm-is-closed/m-p/3175913#M535512</guid>
      <dc:creator>Ankur Bawiskar</dc:creator>
      <dc:date>2025-02-12T13:38:13Z</dc:date>
    </item>
    <item>
      <title>Re: close the task when ritm is closed</title>
      <link>https://www.servicenow.com/community/itsm-forum/close-the-task-when-ritm-is-closed/m-p/3224821#M538406</link>
      <description>&lt;P&gt;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/831651"&gt;@tushar_ghadage&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope you are doing good.&lt;/P&gt;
&lt;P&gt;Did my reply answer your question?&lt;/P&gt;
&lt;P&gt;If my response helped please mark it correct and close the thread so that it benefits future readers.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Apr 2025 03:18:21 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/close-the-task-when-ritm-is-closed/m-p/3224821#M538406</guid>
      <dc:creator>Ankur Bawiskar</dc:creator>
      <dc:date>2025-04-02T03:18:21Z</dc:date>
    </item>
  </channel>
</rss>

