<?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: Calculate the duration of each assignment group spent for each state in an incident in PA in Platform Analytics forum</title>
    <link>https://www.servicenow.com/community/platform-analytics-forum/calculate-the-duration-of-each-assignment-group-spent-for-each/m-p/2742053#M55780</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/272080"&gt;@AndersBGS&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your reply, Yes I could not find anything in OOTB. Could you please guide me where can be do the scripting in PA for achieving this requirement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Vinay T K&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 23 Nov 2023 13:12:11 GMT</pubDate>
    <dc:creator>Vinay T K</dc:creator>
    <dc:date>2023-11-23T13:12:11Z</dc:date>
    <item>
      <title>Calculate the duration of each assignment group spent for each state in an incident in PA</title>
      <link>https://www.servicenow.com/community/platform-analytics-forum/calculate-the-duration-of-each-assignment-group-spent-for-each/m-p/2741919#M55776</link>
      <description>&lt;P&gt;Hi Team,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to know is there any way to calculate the duration of each assignment group spent for each state in an incident in Performance analytics.&lt;/P&gt;&lt;P&gt;eg: INC12345 is in 'work in progress' state and three assignment group worked in this state, such as group A, group B, group C. How to calculate the duration for each group spent under Work in Progress state in PA . Breakdown matrix and breakdown relationship work for this?.&lt;/P&gt;&lt;P&gt;Please share your thought on this.&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;</description>
      <pubDate>Thu, 23 Nov 2023 11:34:47 GMT</pubDate>
      <guid>https://www.servicenow.com/community/platform-analytics-forum/calculate-the-duration-of-each-assignment-group-spent-for-each/m-p/2741919#M55776</guid>
      <dc:creator>Vinay T K</dc:creator>
      <dc:date>2023-11-23T11:34:47Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the duration of each assignment group spent for each state in an incident in PA</title>
      <link>https://www.servicenow.com/community/platform-analytics-forum/calculate-the-duration-of-each-assignment-group-spent-for-each/m-p/2741986#M55777</link>
      <description>&lt;P&gt;HI&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/559165"&gt;@Vinay T K&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;I trust you are doing great.&lt;BR /&gt;If i uderstood the query right the below code will be helpful.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;var incidentSysId = 'sys_id_of_incident'; // Replace with your incident sys_id
var state = 'state_code'; // Replace with your state code
var durationByGroup = {};

var gr = new GlideRecord('incident');
gr.addQuery('sys_id', incidentSysId);
gr.query();

if (gr.next()) {
    var history = new GlideRecord('sys_history_line');
    history.addQuery('field', 'state');
    history.addQuery('new', state);
    history.addQuery('parent', incidentSysId);
    history.orderBy('update_time');
    history.query();

    var startTime;
    var endTime;
    var currentGroup;

    while (history.next()) {
        if (history.getValue('new') == state) {
            startTime = history.update_time;
            currentGroup = gr.assignment_group;
        } else if (history.getValue('old') == state) {
            endTime = history.update_time;

            if (currentGroup) {
                var duration = gs.dateDiff(startTime, endTime, true);
                durationByGroup[currentGroup.getDisplayValue()] = (durationByGroup[currentGroup.getDisplayValue()] || 0) + duration;
            }
        }
    }
}

// Output duration by group
for (var group in durationByGroup) {
    gs.info('Group: ' + group + ', Duration: ' + durationByGroup[group] + ' seconds');
}
&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 23 Nov 2023 12:18:02 GMT</pubDate>
      <guid>https://www.servicenow.com/community/platform-analytics-forum/calculate-the-duration-of-each-assignment-group-spent-for-each/m-p/2741986#M55777</guid>
      <dc:creator>Amit Gujarathi</dc:creator>
      <dc:date>2023-11-23T12:18:02Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the duration of each assignment group spent for each state in an incident in PA</title>
      <link>https://www.servicenow.com/community/platform-analytics-forum/calculate-the-duration-of-each-assignment-group-spent-for-each/m-p/2742015#M55778</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/265565"&gt;@Amit Gujarathi&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your reply, But I am mainly looking this for reporting purpose in the performance analytics. I have already created the database view connecting metric table with incident table, and created indicators for incident state with breakdown incident state and incident assignment group. But it is not showing specific duration respected to the assignment group in each state.&amp;nbsp;&lt;STRONG&gt;&lt;SPAN&gt;Breakdown matrix &lt;/SPAN&gt;&lt;/STRONG&gt;will work for this case?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Vinay T K&lt;/P&gt;</description>
      <pubDate>Thu, 23 Nov 2023 12:41:17 GMT</pubDate>
      <guid>https://www.servicenow.com/community/platform-analytics-forum/calculate-the-duration-of-each-assignment-group-spent-for-each/m-p/2742015#M55778</guid>
      <dc:creator>Vinay T K</dc:creator>
      <dc:date>2023-11-23T12:41:17Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the duration of each assignment group spent for each state in an incident in PA</title>
      <link>https://www.servicenow.com/community/platform-analytics-forum/calculate-the-duration-of-each-assignment-group-spent-for-each/m-p/2742037#M55779</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/559165"&gt;@Vinay T K&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As to my best knowledge, there is no possibility OOTB from performance analytics, as it is two different values that you would like to monitor (state and assignment group). As far as I see it, you need some sort of scripting / custom development to obtain the information.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;Anders&lt;/P&gt;</description>
      <pubDate>Thu, 23 Nov 2023 12:55:58 GMT</pubDate>
      <guid>https://www.servicenow.com/community/platform-analytics-forum/calculate-the-duration-of-each-assignment-group-spent-for-each/m-p/2742037#M55779</guid>
      <dc:creator>AndersBGS</dc:creator>
      <dc:date>2023-11-23T12:55:58Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the duration of each assignment group spent for each state in an incident in PA</title>
      <link>https://www.servicenow.com/community/platform-analytics-forum/calculate-the-duration-of-each-assignment-group-spent-for-each/m-p/2742053#M55780</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/272080"&gt;@AndersBGS&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your reply, Yes I could not find anything in OOTB. Could you please guide me where can be do the scripting in PA for achieving this requirement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Vinay T K&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Nov 2023 13:12:11 GMT</pubDate>
      <guid>https://www.servicenow.com/community/platform-analytics-forum/calculate-the-duration-of-each-assignment-group-spent-for-each/m-p/2742053#M55780</guid>
      <dc:creator>Vinay T K</dc:creator>
      <dc:date>2023-11-23T13:12:11Z</dc:date>
    </item>
  </channel>
</rss>

