<?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: Metric Definition Script to exclude weekends in Developer forum</title>
    <link>https://www.servicenow.com/community/developer-forum/metric-definition-script-to-exclude-weekends/m-p/2253595#M904699</link>
    <description>&lt;P&gt;Use case 2.1 should help you in below blog&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.servicenow.com/community/community?id=community_blog&amp;amp;sys_id=467c62e1dbd0dbc01dcaf3231f9619ad" rel="nofollow"&gt;https://community.servicenow.com/community?id=community_blog&amp;amp;sys_id=467c62e1dbd0dbc01dcaf3231f9619ad&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use a schedule and set your work end time.&lt;/P&gt;</description>
    <pubDate>Tue, 27 Nov 2018 00:52:21 GMT</pubDate>
    <dc:creator>SanjivMeher</dc:creator>
    <dc:date>2018-11-27T00:52:21Z</dc:date>
    <item>
      <title>Metric Definition Script to exclude weekends</title>
      <link>https://www.servicenow.com/community/developer-forum/metric-definition-script-to-exclude-weekends/m-p/2253594#M904698</link>
      <description>&lt;P&gt;Team - I have a metric set up in our change table to record the time between the end date of the change and when it is closed. Creating the metric has improved our Change Manager's ability to manage compliance, however they have identified that time over a weekend should not be included - ie if a change finishes at 1PM on Friday and is closed at 1 PM on the following Monday it should capture 1 day (24 hours)&lt;/P&gt;
&lt;P&gt;Is anybody able to assist - below is the current code working as initially requested:&lt;/P&gt;
&lt;P&gt;Cheers&lt;/P&gt;
&lt;DIV style="padding-left: 30px;"&gt;&lt;EM&gt;if (current.state == 3)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; createMetric();&lt;/EM&gt;&lt;/DIV&gt;
&lt;DIV style="padding-left: 30px;"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV style="padding-left: 30px;"&gt;&lt;EM&gt;if (current.state == 4)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; createMetric();&lt;/EM&gt;&lt;/DIV&gt;
&lt;DIV style="padding-left: 30px;"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV style="padding-left: 30px;"&gt;&lt;EM&gt;function createMetric() {&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; var mi = new MetricInstance(definition, current);&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; if (mi.metricExists()) &lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return;&lt;/EM&gt;&lt;/DIV&gt;
&lt;DIV style="padding-left: 30px;"&gt;&lt;EM&gt;&amp;nbsp; var gr = mi.getNewRecord();&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; gr.start = current.work_end;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; gr.end = current.closed_at;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; gr.duration = gs.dateDiff(gr.start, gr.end);&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; gr.calculation_complete = true;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; gr.insert();&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;}&lt;/EM&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 27 Nov 2018 00:46:55 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/metric-definition-script-to-exclude-weekends/m-p/2253594#M904698</guid>
      <dc:creator>andrewdunn</dc:creator>
      <dc:date>2018-11-27T00:46:55Z</dc:date>
    </item>
    <item>
      <title>Re: Metric Definition Script to exclude weekends</title>
      <link>https://www.servicenow.com/community/developer-forum/metric-definition-script-to-exclude-weekends/m-p/2253595#M904699</link>
      <description>&lt;P&gt;Use case 2.1 should help you in below blog&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.servicenow.com/community/community?id=community_blog&amp;amp;sys_id=467c62e1dbd0dbc01dcaf3231f9619ad" rel="nofollow"&gt;https://community.servicenow.com/community?id=community_blog&amp;amp;sys_id=467c62e1dbd0dbc01dcaf3231f9619ad&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use a schedule and set your work end time.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Nov 2018 00:52:21 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/metric-definition-script-to-exclude-weekends/m-p/2253595#M904699</guid>
      <dc:creator>SanjivMeher</dc:creator>
      <dc:date>2018-11-27T00:52:21Z</dc:date>
    </item>
  </channel>
</rss>

