<?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 Updating Assignment on the RITM and REQ when it is changed on the CTASK in ITSM forum</title>
    <link>https://www.servicenow.com/community/itsm-forum/updating-assignment-on-the-ritm-and-req-when-it-is-changed-on/m-p/2713405#M505892</link>
    <description>&lt;P&gt;Good afternoon!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to set up a business rule so that when the "Assignment Group" OR "Assigned To" is changed on the Catalog Task, the related Request Item and Request are updated with the same group or technician. Currently, when I updated the assignment group or the assigned to user, nothing changes on the RITM or the REQ records. I'm hoping someone can identify what's incorrect in my script. Thanks!&lt;BR /&gt;&lt;BR /&gt;I have set up the following.&lt;BR /&gt;&lt;BR /&gt;Business Rule:&lt;BR /&gt;Table: Catalog Task [sc_task}&lt;/P&gt;&lt;P&gt;When to run: after update&lt;BR /&gt;Condition: Assigned to changes OR Assignment Group Changes&lt;BR /&gt;Script:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;(function executeRule(current, previous /*, display*/) {
    // Check if the 'assigned_to' field has been changed
    if (current.assignment_group.changes() || current.assigned_to.changes()) {
        // Get the Requested Item associated with the Catalog Task
        var requestedItem = new GlideRecord('sc_req_item');
        if (requestedItem.get(current.cat_item)) {
            // Update the Requested Item's assigned_to with the Catalog Task's assigned_to
            requestedItem.assigned_to = current.assigned_to;
            requestedItem.update();
        }

        // Get the Request associated with the Catalog Task
        var request = new GlideRecord('sc_request');
        if (request.get(current.request)) {
            // Update the Request's assigned_to with the Catalog Task's assigned_to
            request.assigned_to = current.assigned_to;
            request.update();
        }
    }
})(current, previous);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Screenshots:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DTrishman_0-1698253086428.png" style="width: 400px;"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/300103iC69DEA8F8842D48A/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="DTrishman_0-1698253086428.png" alt="DTrishman_0-1698253086428.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DTrishman_1-1698253112891.png" style="width: 400px;"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/300104i0C67620EE9A7C84D/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="DTrishman_1-1698253112891.png" alt="DTrishman_1-1698253112891.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 25 Oct 2023 17:02:14 GMT</pubDate>
    <dc:creator>DTrishman</dc:creator>
    <dc:date>2023-10-25T17:02:14Z</dc:date>
    <item>
      <title>Updating Assignment on the RITM and REQ when it is changed on the CTASK</title>
      <link>https://www.servicenow.com/community/itsm-forum/updating-assignment-on-the-ritm-and-req-when-it-is-changed-on/m-p/2713405#M505892</link>
      <description>&lt;P&gt;Good afternoon!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to set up a business rule so that when the "Assignment Group" OR "Assigned To" is changed on the Catalog Task, the related Request Item and Request are updated with the same group or technician. Currently, when I updated the assignment group or the assigned to user, nothing changes on the RITM or the REQ records. I'm hoping someone can identify what's incorrect in my script. Thanks!&lt;BR /&gt;&lt;BR /&gt;I have set up the following.&lt;BR /&gt;&lt;BR /&gt;Business Rule:&lt;BR /&gt;Table: Catalog Task [sc_task}&lt;/P&gt;&lt;P&gt;When to run: after update&lt;BR /&gt;Condition: Assigned to changes OR Assignment Group Changes&lt;BR /&gt;Script:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;(function executeRule(current, previous /*, display*/) {
    // Check if the 'assigned_to' field has been changed
    if (current.assignment_group.changes() || current.assigned_to.changes()) {
        // Get the Requested Item associated with the Catalog Task
        var requestedItem = new GlideRecord('sc_req_item');
        if (requestedItem.get(current.cat_item)) {
            // Update the Requested Item's assigned_to with the Catalog Task's assigned_to
            requestedItem.assigned_to = current.assigned_to;
            requestedItem.update();
        }

        // Get the Request associated with the Catalog Task
        var request = new GlideRecord('sc_request');
        if (request.get(current.request)) {
            // Update the Request's assigned_to with the Catalog Task's assigned_to
            request.assigned_to = current.assigned_to;
            request.update();
        }
    }
})(current, previous);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Screenshots:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DTrishman_0-1698253086428.png" style="width: 400px;"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/300103iC69DEA8F8842D48A/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="DTrishman_0-1698253086428.png" alt="DTrishman_0-1698253086428.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DTrishman_1-1698253112891.png" style="width: 400px;"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/300104i0C67620EE9A7C84D/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="DTrishman_1-1698253112891.png" alt="DTrishman_1-1698253112891.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2023 17:02:14 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/updating-assignment-on-the-ritm-and-req-when-it-is-changed-on/m-p/2713405#M505892</guid>
      <dc:creator>DTrishman</dc:creator>
      <dc:date>2023-10-25T17:02:14Z</dc:date>
    </item>
    <item>
      <title>Re: Updating Assignment on the RITM and REQ when it is changed on the CTASK</title>
      <link>https://www.servicenow.com/community/itsm-forum/updating-assignment-on-the-ritm-and-req-when-it-is-changed-on/m-p/2713487#M505896</link>
      <description>&lt;P&gt;Since you have the filter conditions, there's no need to repeat the same with your script wrapped in an if statement, but it's not really hurting anything.&amp;nbsp; Since this rule is running on the sc_task table, 'current' refers to the sc_task record that was just updated.&amp;nbsp; The cat_item field references the Catalog Item that the RITM is associated with, so you'll want to use request_item instead:&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;        if (requestedItem.get(current.request_item)) {
            // Update the Requested Item's assigned_to with the Catalog Task's assigned_to
            requestedItem.assigned_to = current.assigned_to;
            requestedItem.update();
&lt;/LI-CODE&gt;
&lt;P&gt;Note that you aren't doing anything to update the assignment_group or distinguishing which changed.&amp;nbsp; Your second GlideRecord looks OK, but if the REQ is not updating, maybe 'request' is a reserved/key word so you should change this var name, or there is another Business Rule also affecting the assigned_to, or the opening if statement is precluding anything from running.&amp;nbsp; You can add some gs.info lines to log what's going on.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2023 18:35:08 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/updating-assignment-on-the-ritm-and-req-when-it-is-changed-on/m-p/2713487#M505896</guid>
      <dc:creator>Brad Bowman</dc:creator>
      <dc:date>2023-10-25T18:35:08Z</dc:date>
    </item>
    <item>
      <title>Re: Updating Assignment on the RITM and REQ when it is changed on the CTASK</title>
      <link>https://www.servicenow.com/community/itsm-forum/updating-assignment-on-the-ritm-and-req-when-it-is-changed-on/m-p/2713592#M505901</link>
      <description>&lt;P&gt;This was my issue. Thanks so much for your help.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2023 21:19:38 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/updating-assignment-on-the-ritm-and-req-when-it-is-changed-on/m-p/2713592#M505901</guid>
      <dc:creator>DTrishman</dc:creator>
      <dc:date>2023-10-25T21:19:38Z</dc:date>
    </item>
    <item>
      <title>Re: Updating Assignment on the RITM and REQ when it is changed on the CTASK</title>
      <link>https://www.servicenow.com/community/itsm-forum/updating-assignment-on-the-ritm-and-req-when-it-is-changed-on/m-p/2714349#M505977</link>
      <description>&lt;P&gt;You are welcome!&lt;/P&gt;</description>
      <pubDate>Thu, 26 Oct 2023 12:25:11 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/updating-assignment-on-the-ritm-and-req-when-it-is-changed-on/m-p/2714349#M505977</guid>
      <dc:creator>Brad Bowman</dc:creator>
      <dc:date>2023-10-26T12:25:11Z</dc:date>
    </item>
    <item>
      <title>Re: Updating Assignment on the RITM and REQ when it is changed on the CTASK</title>
      <link>https://www.servicenow.com/community/itsm-forum/updating-assignment-on-the-ritm-and-req-when-it-is-changed-on/m-p/2804095#M512605</link>
      <description>&lt;P&gt;I used this and got the assigned to to change, but the assigned group did not. Is that missing from the code?&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jan 2024 21:47:17 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/updating-assignment-on-the-ritm-and-req-when-it-is-changed-on/m-p/2804095#M512605</guid>
      <dc:creator>Stacy Ricco</dc:creator>
      <dc:date>2024-01-24T21:47:17Z</dc:date>
    </item>
    <item>
      <title>Re: Updating Assignment on the RITM and REQ when it is changed on the CTASK</title>
      <link>https://www.servicenow.com/community/itsm-forum/updating-assignment-on-the-ritm-and-req-when-it-is-changed-on/m-p/2804945#M512653</link>
      <description>&lt;P&gt;Yes, this was not included in the solution as I was working off of the author's initial attempt.&amp;nbsp; If you want to do update the Assignment group from the task you could just add a line before the update:&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;requestedItem.assignment_group = current.assignment_group;
&lt;/LI-CODE&gt;
&lt;P&gt;but this would just update both anytime either changed, so if you want to be more selective, split the rule into two or split the script into two sections - if assignment group changes update assignment group, if assigned to changes update assigned to...&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jan 2024 13:36:17 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/updating-assignment-on-the-ritm-and-req-when-it-is-changed-on/m-p/2804945#M512653</guid>
      <dc:creator>Brad Bowman</dc:creator>
      <dc:date>2024-01-25T13:36:17Z</dc:date>
    </item>
  </channel>
</rss>

