<?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 Script not working in Developer forum</title>
    <link>https://www.servicenow.com/community/developer-forum/script-not-working/m-p/3201426#M1185865</link>
    <description>&lt;P&gt;Hi all&lt;/P&gt;&lt;P&gt;I am using below business rule on user table after update and active changes to false, everything is working fine state getting update worknotes getting updated but autosysfields not working, please suggest&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;function&lt;/SPAN&gt;&lt;SPAN&gt; executeRule(current, previous &lt;/SPAN&gt;&lt;SPAN&gt;/*null when async*/&lt;/SPAN&gt;&lt;SPAN&gt; ) {&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;var&lt;/SPAN&gt;&lt;SPAN&gt; grScReqItem = &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;'sc_req_item'&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; grScReqItem.addEncodedQuery(&lt;/SPAN&gt;&lt;SPAN&gt;"cat_item=32524947c32b9a1062c17ebdc00131a5^stateNOT IN3,4,7^requested_for="&lt;/SPAN&gt;&lt;SPAN&gt; + current.sys_id);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; grScReqItem.query();&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; (grScReqItem.next()) {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;STRONG&gt;&amp;nbsp; &amp;nbsp; grScReqItem.setWorkflow(false);&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;grScReqItem.autoSysFields(false);&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; grScReqItem.work_notes = &lt;/SPAN&gt;&lt;SPAN&gt;"RITM is closed incomplete as the requestor has been deactivated."&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; grScReqItem.state = &lt;/SPAN&gt;&lt;SPAN&gt;"4"&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; grScReqItem.update();&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;&lt;SPAN&gt;})(current, previous);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Mon, 10 Mar 2025 13:13:08 GMT</pubDate>
    <dc:creator>sunil10</dc:creator>
    <dc:date>2025-03-10T13:13:08Z</dc:date>
    <item>
      <title>Script not working</title>
      <link>https://www.servicenow.com/community/developer-forum/script-not-working/m-p/3201426#M1185865</link>
      <description>&lt;P&gt;Hi all&lt;/P&gt;&lt;P&gt;I am using below business rule on user table after update and active changes to false, everything is working fine state getting update worknotes getting updated but autosysfields not working, please suggest&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;function&lt;/SPAN&gt;&lt;SPAN&gt; executeRule(current, previous &lt;/SPAN&gt;&lt;SPAN&gt;/*null when async*/&lt;/SPAN&gt;&lt;SPAN&gt; ) {&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;var&lt;/SPAN&gt;&lt;SPAN&gt; grScReqItem = &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;'sc_req_item'&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; grScReqItem.addEncodedQuery(&lt;/SPAN&gt;&lt;SPAN&gt;"cat_item=32524947c32b9a1062c17ebdc00131a5^stateNOT IN3,4,7^requested_for="&lt;/SPAN&gt;&lt;SPAN&gt; + current.sys_id);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; grScReqItem.query();&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; (grScReqItem.next()) {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;STRONG&gt;&amp;nbsp; &amp;nbsp; grScReqItem.setWorkflow(false);&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;grScReqItem.autoSysFields(false);&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; grScReqItem.work_notes = &lt;/SPAN&gt;&lt;SPAN&gt;"RITM is closed incomplete as the requestor has been deactivated."&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; grScReqItem.state = &lt;/SPAN&gt;&lt;SPAN&gt;"4"&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; grScReqItem.update();&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;&lt;SPAN&gt;})(current, previous);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 10 Mar 2025 13:13:08 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/script-not-working/m-p/3201426#M1185865</guid>
      <dc:creator>sunil10</dc:creator>
      <dc:date>2025-03-10T13:13:08Z</dc:date>
    </item>
    <item>
      <title>Re: Script not working</title>
      <link>https://www.servicenow.com/community/developer-forum/script-not-working/m-p/3201461#M1185873</link>
      <description>&lt;P&gt;To clarify, are you saying that you don't want fields like updated by and updated on (or which fields specifically) to be updated when this rule triggers but they are getting updated, or they aren't updated and you want them to be updated?&lt;/P&gt;</description>
      <pubDate>Mon, 10 Mar 2025 13:24:39 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/script-not-working/m-p/3201461#M1185873</guid>
      <dc:creator>Brad Bowman</dc:creator>
      <dc:date>2025-03-10T13:24:39Z</dc:date>
    </item>
    <item>
      <title>Re: Script not working</title>
      <link>https://www.servicenow.com/community/developer-forum/script-not-working/m-p/3201478#M1185879</link>
      <description>&lt;P&gt;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/174062"&gt;@Brad Bowman &lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Script is working fine as required only issue i am facing is when worknotes and state getting update it is showing my name instead system&lt;/P&gt;</description>
      <pubDate>Mon, 10 Mar 2025 13:27:16 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/script-not-working/m-p/3201478#M1185879</guid>
      <dc:creator>sunil10</dc:creator>
      <dc:date>2025-03-10T13:27:16Z</dc:date>
    </item>
    <item>
      <title>Re: Script not working</title>
      <link>https://www.servicenow.com/community/developer-forum/script-not-working/m-p/3201500#M1185886</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sunil10_0-1741613763070.png"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/425428i6B6182BD7818218A/image-size/medium?v=v2&amp;amp;px=400" alt="sunil10_0-1741613763070.png" title="sunil10_0-1741613763070.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Mar 2025 13:36:11 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/script-not-working/m-p/3201500#M1185886</guid>
      <dc:creator>sunil10</dc:creator>
      <dc:date>2025-03-10T13:36:11Z</dc:date>
    </item>
    <item>
      <title>Re: Script not working</title>
      <link>https://www.servicenow.com/community/developer-forum/script-not-working/m-p/3201508#M1185891</link>
      <description>&lt;P&gt;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/88180"&gt;@sunil10&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ideally let the name be shown of that user who performs the action via the business rule.&lt;/P&gt;
&lt;P&gt;what's your concern?&lt;/P&gt;
&lt;P&gt;why you want to want with some other user?&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>Mon, 10 Mar 2025 13:41:31 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/script-not-working/m-p/3201508#M1185891</guid>
      <dc:creator>Ankur Bawiskar</dc:creator>
      <dc:date>2025-03-10T13:41:31Z</dc:date>
    </item>
    <item>
      <title>Re: Script not working</title>
      <link>https://www.servicenow.com/community/developer-forum/script-not-working/m-p/3201509#M1185892</link>
      <description>&lt;P&gt;you need to show updated by system?&lt;/P&gt;</description>
      <pubDate>Mon, 10 Mar 2025 13:46:51 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/script-not-working/m-p/3201509#M1185892</guid>
      <dc:creator>Ankit_Matta</dc:creator>
      <dc:date>2025-03-10T13:46:51Z</dc:date>
    </item>
    <item>
      <title>Re: Script not working</title>
      <link>https://www.servicenow.com/community/developer-forum/script-not-working/m-p/3201510#M1185893</link>
      <description>&lt;P&gt;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/88180"&gt;@sunil10&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;can you try this&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;(function executeRule(current, previous /*null when async*/) {
    var grScReqItem = new GlideRecord('sc_req_item');
    grScReqItem.addEncodedQuery("cat_item=32524947c32b9a1062c17ebdc00131a5^stateNOT IN3,4,7^requested_for=" + current.sys_id);
    grScReqItem.query();
    while (grScReqItem.next()) {
        grScReqItem.setWorkflow(false);
        grScReqItem.autoSysFields(false);

        // Update work notes without including the user's name
        grScReqItem.work_notes = "RITM is closed incomplete as the requestor has been deactivated.";
        grScReqItem.state = "4";
        grScReqItem.update();
    }
})(current, previous);&lt;/LI-CODE&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>Mon, 10 Mar 2025 13:43:20 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/script-not-working/m-p/3201510#M1185893</guid>
      <dc:creator>Ankur Bawiskar</dc:creator>
      <dc:date>2025-03-10T13:43:20Z</dc:date>
    </item>
    <item>
      <title>Re: Script not working</title>
      <link>https://www.servicenow.com/community/developer-forum/script-not-working/m-p/3201519#M1185896</link>
      <description>&lt;P&gt;autoSysFields(false) disables&amp;nbsp;&lt;SPAN&gt;updates to sys_updated_by, sys_updated_on, sys_mod_count, sys_created_by, and sys_created_on fields, which is not necessarily the same as something appearing in the activity stream.&amp;nbsp; Can you confirm on the updated record that these fields were or or not updated with the change?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Mar 2025 13:47:40 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/script-not-working/m-p/3201519#M1185896</guid>
      <dc:creator>Brad Bowman</dc:creator>
      <dc:date>2025-03-10T13:47:40Z</dc:date>
    </item>
    <item>
      <title>Re: Script not working</title>
      <link>https://www.servicenow.com/community/developer-forum/script-not-working/m-p/3201529#M1185901</link>
      <description>&lt;P&gt;My suggestion would be to not use "setWorkflow(false)" nor "autoSysFields(false)" when you are updating a real production data as part of user deactivation process. Those methods are helpful in case you are mass-updating data to just fix one field value for example. But in standard business process dangerous - e.g., turning off business rules might end up that a) SLAs running on RITM will not be completed, b) Metric Instances on RITM might not be completed and so on... many data inconsistency issues might pop up.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the only problem is that your name is there - which is probably because you deactivated the user in your session, and onAfter BR run also under your session, then try to decouple the actions of 1) who is deactivating the user, 2) who is updating the RITMs. You can try "Async BR" if that is decoupling it from your session, or you could generate an event (like "sys_user.deactivated") in onAfter BR and have "Script Action" to be executed out of that event - then it would probably run under "system". I did not test any of these, but maybe it can help you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Dominik&lt;/P&gt;</description>
      <pubDate>Mon, 10 Mar 2025 13:50:31 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/script-not-working/m-p/3201529#M1185901</guid>
      <dc:creator>Dominik Simunek</dc:creator>
      <dc:date>2025-03-10T13:50:31Z</dc:date>
    </item>
    <item>
      <title>Re: Script not working</title>
      <link>https://www.servicenow.com/community/developer-forum/script-not-working/m-p/3201531#M1185903</link>
      <description>&lt;P&gt;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/265966"&gt;@Ankur Bawiskar&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;tried with your code state is getting updated only , then nothing happens worknotes also no updated&lt;/P&gt;</description>
      <pubDate>Mon, 10 Mar 2025 13:51:01 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/script-not-working/m-p/3201531#M1185903</guid>
      <dc:creator>sunil10</dc:creator>
      <dc:date>2025-03-10T13:51:01Z</dc:date>
    </item>
    <item>
      <title>Re: Script not working</title>
      <link>https://www.servicenow.com/community/developer-forum/script-not-working/m-p/3201537#M1185907</link>
      <description>&lt;P&gt;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/657077"&gt;@Ankit_Matta&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Is this line "&amp;nbsp;grScReqItem.autoSysFields(false);"&amp;nbsp; &amp;nbsp; &amp;nbsp;working ?&amp;nbsp; ---This is the only issue it is not working&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Mar 2025 13:51:51 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/script-not-working/m-p/3201537#M1185907</guid>
      <dc:creator>sunil10</dc:creator>
      <dc:date>2025-03-10T13:51:51Z</dc:date>
    </item>
    <item>
      <title>Re: Script not working</title>
      <link>https://www.servicenow.com/community/developer-forum/script-not-working/m-p/3201542#M1185911</link>
      <description>&lt;P&gt;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/88180"&gt;@sunil10&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I will recommend not using those 2 lines and let it be audited and let subsequent logic run whenever RITM state is getting updated.&lt;/P&gt;
&lt;P&gt;This will help from audit point of view as well.&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>Mon, 10 Mar 2025 13:55:19 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/script-not-working/m-p/3201542#M1185911</guid>
      <dc:creator>Ankur Bawiskar</dc:creator>
      <dc:date>2025-03-10T13:55:19Z</dc:date>
    </item>
    <item>
      <title>Re: Script not working</title>
      <link>https://www.servicenow.com/community/developer-forum/script-not-working/m-p/3201576#M1185932</link>
      <description>&lt;P&gt;Rather than a Business Rule, you can run this script as a scheduled job - nightly, weekly, or whatever close RITMs that were opened by users who are now inactive...&amp;nbsp; In the scheduled job setup there is an option to run the script as a certain user.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="BradBowman_0-1741616102206.png"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/425438i6DB38E6CCFCB3E46/image-dimensions/667x75?v=v2" alt="BradBowman_0-1741616102206.png" title="BradBowman_0-1741616102206.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Mar 2025 14:15:18 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/script-not-working/m-p/3201576#M1185932</guid>
      <dc:creator>Brad Bowman</dc:creator>
      <dc:date>2025-03-10T14:15:18Z</dc:date>
    </item>
  </channel>
</rss>

