<?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 auto close Requested item after 7 days same as incident in Developer forum</title>
    <link>https://www.servicenow.com/community/developer-forum/how-to-auto-close-requested-item-after-7-days-same-as-incident/m-p/1394314#M51240</link>
    <description>&lt;P&gt;I think the previous developer get the technic from this website. Its literally same.&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 30 Jun 2020 04:17:16 GMT</pubDate>
    <dc:creator>zulhiyatiuwi</dc:creator>
    <dc:date>2020-06-30T04:17:16Z</dc:date>
    <item>
      <title>How to auto close Requested item after 7 days same as incident</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-auto-close-requested-item-after-7-days-same-as-incident/m-p/1394310#M51236</link>
      <description>&lt;P&gt;Hello Team,&lt;/P&gt;
&lt;P&gt;I'm trying to set auto close a request after 7 days. I have written business rule and schedule job but didn't worked can any one help me how to close the request.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Scheduled Job :&lt;/STRONG&gt;&lt;/P&gt;
&lt;DIV&gt;&lt;SPAN style="background-color: #ffffff;"&gt;var query = 'state=4^sys_updated_onRELATIVELT@dayofweek@ago@7'; //state is resolved&lt;BR /&gt;var gr = new GlideRecord('table name');&lt;BR /&gt;gr.addEncodedQuery(query);&lt;BR /&gt;gr.query();&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="background-color: #ffffff;"&gt;while(gr.next()){&lt;BR /&gt;gr.state = '5'; //set the state to closed&lt;BR /&gt;gr.update();&lt;BR /&gt;}&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Business rule is same as incident one for autoclose.&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Thanks,&lt;/DIV&gt;
&lt;DIV&gt;Chaitanya&lt;/DIV&gt;</description>
      <pubDate>Tue, 30 Jun 2020 03:37:07 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-auto-close-requested-item-after-7-days-same-as-incident/m-p/1394310#M51236</guid>
      <dc:creator>Chaitanya Redd1</dc:creator>
      <dc:date>2020-06-30T03:37:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to auto close Requested item after 7 days same as incident</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-auto-close-requested-item-after-7-days-same-as-incident/m-p/1394311#M51237</link>
      <description>&lt;P&gt;I have the same&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Create BR: When to run is after but without any condition&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper"&gt;&lt;img src="https://www.servicenow.com/community/s/skins/images/B9CAAB319153FD403AE46876C2AEA9E7/responsive_peak/images/image_not_found.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;and the script. This request have the same time with incident. if you want to change it, just add your time in var ps = 7;&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;autoCloseRequest();

function autoCloseRequest() {
    var ps = gs.getProperty('glide.ui.autoclose.time');
    var pn = parseInt(ps);
    var queryTime = new GlideDateTime();
    queryTime.addDaysUTC(-pn);

    if (pn &amp;gt; 0) {
        var gr = new GlideRecord('sc_req_item');
        gr.addQuery('state', '5');
        gr.addQuery('sys_updated_on', '&amp;lt;', queryTime);
        gr.addQuery('u_coh', 'false');
        while (gr.next()) {
            gr.state = '3';
            gr.comments = 'Request ditutup otomatis setelah ' + pn + ' hari dari tiket diselesaikan.';
            gr.active = false;
            gr.update();
        }
    }
}&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P style="top: 459px;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="top: 459px;"&gt;And then create the scheduled job.&amp;nbsp;fcScriptName=&lt;STRONG&gt;request autoclose&lt;/STRONG&gt;, is the BR that create before. and it will run every 1 hour.&lt;/P&gt;
&lt;P style="top: 459px;"&gt;&lt;span class="lia-inline-image-display-wrapper"&gt;&lt;img src="https://www.servicenow.com/community/s/skins/images/B9CAAB319153FD403AE46876C2AEA9E7/responsive_peak/images/image_not_found.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P style="top: 459px;"&gt;this is working fine in the instance. hope this will give you little help.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jun 2020 03:52:48 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-auto-close-requested-item-after-7-days-same-as-incident/m-p/1394311#M51237</guid>
      <dc:creator>zulhiyatiuwi</dc:creator>
      <dc:date>2020-06-30T03:52:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to auto close Requested item after 7 days same as incident</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-auto-close-requested-item-after-7-days-same-as-incident/m-p/1394312#M51238</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Write a Schedule job for this requirement which runs every day&lt;/P&gt;
&lt;P&gt;var query = 'state=-4^sys_updated_onRELATIVELT@dayofweek@ago@7'; //state is resolved&lt;BR /&gt;var gr = new GlideRecord('table_name');&lt;BR /&gt;gr.addEncodedQuery(query);&lt;BR /&gt;gr.query();&lt;/P&gt;
&lt;P&gt;while(gr.next()){&lt;BR /&gt;gr.state = '3'; //set the state to closed&lt;BR /&gt;gr.update();&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please Mark it helpful/Correct if it helps you&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jun 2020 03:54:50 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-auto-close-requested-item-after-7-days-same-as-incident/m-p/1394312#M51238</guid>
      <dc:creator>Ankush Jangle1</dc:creator>
      <dc:date>2020-06-30T03:54:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to auto close Requested item after 7 days same as incident</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-auto-close-requested-item-after-7-days-same-as-incident/m-p/1394313#M51239</link>
      <description>&lt;P&gt;Hey&amp;nbsp;Chaitanya,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In addition to above post refer the Link, it might help you:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;A href="https://medium.com/servicenow-techminds/how-to-auto-close-resolved-incidents-after-7-days-in-service-now-d9041547ad98" rel="nofollow"&gt;https://medium.com/servicenow-techminds/how-to-auto-close-resolved-incidents-after-7-days-in-service-now-d9041547ad98&lt;/A&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Mark &lt;STRONG&gt;Correct&lt;/STRONG&gt; and &lt;STRONG&gt;Helpful&lt;/STRONG&gt; if you find my response worthy!!!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Namrata.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jun 2020 04:03:00 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-auto-close-requested-item-after-7-days-same-as-incident/m-p/1394313#M51239</guid>
      <dc:creator>Namrata Khabale</dc:creator>
      <dc:date>2020-06-30T04:03:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to auto close Requested item after 7 days same as incident</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-auto-close-requested-item-after-7-days-same-as-incident/m-p/1394314#M51240</link>
      <description>&lt;P&gt;I think the previous developer get the technic from this website. Its literally same.&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jun 2020 04:17:16 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-auto-close-requested-item-after-7-days-same-as-incident/m-p/1394314#M51240</guid>
      <dc:creator>zulhiyatiuwi</dc:creator>
      <dc:date>2020-06-30T04:17:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to auto close Requested item after 7 days same as incident</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-auto-close-requested-item-after-7-days-same-as-incident/m-p/1394315#M51241</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Step 1&lt;/P&gt;
&lt;P&gt;Business rule name : RITM autoclose&amp;nbsp;&lt;BR /&gt;After BR on sc_req_item table&lt;/P&gt;
&lt;P&gt;autoCloseRITMs();&lt;/P&gt;
&lt;P&gt;function autoCloseRITMs() {&lt;BR /&gt; var ps = gs.getProperty('glide.ui.autoclose.time');&lt;BR /&gt; var pn = parseInt(ps);&lt;BR /&gt; var queryTime = new GlideDateTime();&lt;BR /&gt; queryTime.addDaysUTC(-pn);&lt;/P&gt;
&lt;P&gt;if (pn &amp;gt; 0) {&lt;BR /&gt; var gr = new GlideRecord('sc_req_item');&lt;BR /&gt; gr.addQuery('sys_updated_on', '&amp;lt;', queryTime);&lt;BR /&gt; gr.query();&lt;BR /&gt; while(gr.next()) {&lt;BR /&gt; gr.state = 3;&lt;BR /&gt; gr.comments = 'RITM automatically closed after ' + pn + ' days without any update on the RITM record.';&lt;BR /&gt; gr.active = false;&lt;BR /&gt; gr.closed_by = gr.resolved_by;&lt;BR /&gt; gr.update();&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Step2&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Scheduled Job&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="find_real_file.png"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/140352i1F71BA4680617C7A/image-size/large?v=v2&amp;amp;px=999" role="button" title="find_real_file.png" alt="find_real_file.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Mark &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; Correct if my response solves your issue and also mark &lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt; Helpful if you find my answer helps you based on the impact.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jun 2020 04:18:50 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-auto-close-requested-item-after-7-days-same-as-incident/m-p/1394315#M51241</guid>
      <dc:creator>Shantharao</dc:creator>
      <dc:date>2020-06-30T04:18:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to auto close Requested item after 7 days same as incident</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-auto-close-requested-item-after-7-days-same-as-incident/m-p/1394316#M51242</link>
      <description>&lt;P&gt;&lt;A href="https://community.servicenow.com/community?id=community_blog&amp;amp;sys_id=ae9caee1dbd0dbc01dcaf3231f96193d" rel="nofollow"&gt;Scriptless Scheduled Jobs&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.servicenow.com/community?id=community_blog&amp;amp;sys_id=ae9caee1dbd0dbc01dcaf3231f96193d" rel="nofollow"&gt;Autoclose Incidents&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jun 2020 04:24:56 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-auto-close-requested-item-after-7-days-same-as-incident/m-p/1394316#M51242</guid>
      <dc:creator>Krishna  Penaka</dc:creator>
      <dc:date>2020-06-30T04:24:56Z</dc:date>
    </item>
  </channel>
</rss>

