<?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: Comparing updated_by and opened_by fields from task table in Developer forum</title>
    <link>https://www.servicenow.com/community/developer-forum/comparing-updated-by-and-opened-by-fields-from-task-table/m-p/3058074#M1148827</link>
    <description>&lt;P&gt;I think it's a good idea to use dot walking to get the email address.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;H3&gt;Why&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;updated_by&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;is a String and not a Reference:&lt;/H3&gt;&lt;P&gt;The&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;updated_by&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;field is likely designed as a string for efficiency, as storing user information directly as a string might reduce database lookups for frequently updated fields. Since it's often a field that changes regularly, keeping it as a simple data type could be advantageous in terms of performance, even though it sacrifices the flexibility of reference fields.&lt;/P&gt;&lt;P&gt;It's also possible that they're simply holding onto an older design.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 27 Sep 2024 13:11:47 GMT</pubDate>
    <dc:creator>HIROSHI SATOH</dc:creator>
    <dc:date>2024-09-27T13:11:47Z</dc:date>
    <item>
      <title>Comparing updated_by and opened_by fields from task table</title>
      <link>https://www.servicenow.com/community/developer-forum/comparing-updated-by-and-opened-by-fields-from-task-table/m-p/3057921#M1148772</link>
      <description>&lt;P&gt;I have a custom incident table that is extending the task table. I would like implement a logic that:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Re-opens incidents from this table that are in state "&lt;EM&gt;Solution Proposed"&lt;/EM&gt; if the person who opened the incident updates it within 14 days after the incident changes to state "Solution Proposed". &amp;nbsp;So updated_by ==&amp;nbsp;opened_by.&lt;/LI&gt;&lt;LI&gt;Auto-closes incidents that have been in the state "Solution Proposed" for more than 14 days.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;I am seeing that the ootb task table field updated_by is a String field containing the email of the user that updated the ticket last. The opened_by field however, with which i would like to make the comparison on, is a reference field. Is dot-walking on the opened_by field to find the email and then transforming it to a String the only way to make a comparison between the two fields? And why is the updated_by field a String and not a Reference?&lt;/P&gt;</description>
      <pubDate>Fri, 27 Sep 2024 10:10:37 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/comparing-updated-by-and-opened-by-fields-from-task-table/m-p/3057921#M1148772</guid>
      <dc:creator>Anthony Okoth</dc:creator>
      <dc:date>2024-09-27T10:10:37Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing updated_by and opened_by fields from task table</title>
      <link>https://www.servicenow.com/community/developer-forum/comparing-updated-by-and-opened-by-fields-from-task-table/m-p/3058074#M1148827</link>
      <description>&lt;P&gt;I think it's a good idea to use dot walking to get the email address.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;H3&gt;Why&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;updated_by&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;is a String and not a Reference:&lt;/H3&gt;&lt;P&gt;The&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;updated_by&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;field is likely designed as a string for efficiency, as storing user information directly as a string might reduce database lookups for frequently updated fields. Since it's often a field that changes regularly, keeping it as a simple data type could be advantageous in terms of performance, even though it sacrifices the flexibility of reference fields.&lt;/P&gt;&lt;P&gt;It's also possible that they're simply holding onto an older design.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Sep 2024 13:11:47 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/comparing-updated-by-and-opened-by-fields-from-task-table/m-p/3058074#M1148827</guid>
      <dc:creator>HIROSHI SATOH</dc:creator>
      <dc:date>2024-09-27T13:11:47Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing updated_by and opened_by fields from task table</title>
      <link>https://www.servicenow.com/community/developer-forum/comparing-updated-by-and-opened-by-fields-from-task-table/m-p/3058080#M1148830</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/24150"&gt;@Anthony Okoth&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;you can achieve this requirement by BR or Scheduled job. Following sample script will help you:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;(function() {
    var gr = new GlideRecord('your_custom_incident_table'); 
    gr.addQuery('state', 'Solution Proposed');
    gr.query();

    while (gr.next()) {
        var openedByEmail = gr.opened_by.email; // Get the email of the user who opened the incident
        var updatedByEmail = gr.updated_by; // Get the email of the last user who updated it
        
        // Check if the incident is updated by the person who opened it
        var daysSinceSolutionProposed = gs.dateDiff(gr.solution_proposed_date, new GlideDateTime(), true);
        
        if (daysSinceSolutionProposed &amp;lt;= 14 &amp;amp;&amp;amp; updatedByEmail == openedByEmail) {
            gr.setValue('state', 'Reopened'); // Change to the appropriate state value for "Reopened"
            gr.update();
        } else if (daysSinceSolutionProposed &amp;gt; 14) {
            gr.setValue('state', 'Closed'); // Change to the appropriate state value for "Closed"
            gr.update();
        }
    }
})();&lt;/LI-CODE&gt;&lt;H3&gt;&amp;nbsp;&lt;/H3&gt;&lt;P&gt;Why&amp;nbsp;updated_by is a String?&lt;/P&gt;&lt;P&gt;The updated_by&amp;nbsp;field is a string field because it is intended to hold the email address (or a similar identifier) directly, making it easier to reference or log without needing to perform additional lookups. This allows for quick access to the last updater’s identifier without needing a database join.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i hope my answer helps you to resolve your issue, if yes please mark my answer helpful and correct.&lt;/P&gt;&lt;P&gt;thank you&lt;/P&gt;&lt;P&gt;rajesh&lt;/P&gt;</description>
      <pubDate>Fri, 27 Sep 2024 13:23:49 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/comparing-updated-by-and-opened-by-fields-from-task-table/m-p/3058080#M1148830</guid>
      <dc:creator>Rajesh Chopade1</dc:creator>
      <dc:date>2024-09-27T13:23:49Z</dc:date>
    </item>
  </channel>
</rss>

