<?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 Metric definition should execute based on condition in ITSM forum</title>
    <link>https://www.servicenow.com/community/itsm-forum/metric-definition-should-execute-based-on-condition/m-p/2789040#M511436</link>
    <description>&lt;P&gt;Hi friends,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am creating a metric definition to capture a field value "u_enroll_date".&lt;/P&gt;&lt;P&gt;Requirement is that the field change should be captured only when the "state" field changes to "Delivered." For other "state" field values it should not capture the&amp;nbsp;"u_enroll_date".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code :&lt;/P&gt;&lt;P&gt;var Req = current.state;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;if (Req == 'delivered' || Req == 'Delivered')&lt;/STRONG&gt;&lt;/FONT&gt; {&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //// This condition is not working.&amp;nbsp;&lt;BR /&gt;createMetric();&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;function createMetric() {&lt;BR /&gt;var mi = new MetricInstance(definition, current);&lt;BR /&gt;var gr = mi.getNewRecord();&lt;BR /&gt;gr.value=current.sys_updated_by;&lt;BR /&gt;gr.insert();&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The Condition in RED above is not working. It is creating record in metric every time the state is changes. It should capture only when the state is Ordered.&lt;/P&gt;&lt;P&gt;How to achieve it through metric script. I cannot add this condition to metric definition business rule since it is required for some other fields as well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 16 Jan 2024 05:18:15 GMT</pubDate>
    <dc:creator>Asmita7</dc:creator>
    <dc:date>2024-01-16T05:18:15Z</dc:date>
    <item>
      <title>Metric definition should execute based on condition</title>
      <link>https://www.servicenow.com/community/itsm-forum/metric-definition-should-execute-based-on-condition/m-p/2789040#M511436</link>
      <description>&lt;P&gt;Hi friends,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am creating a metric definition to capture a field value "u_enroll_date".&lt;/P&gt;&lt;P&gt;Requirement is that the field change should be captured only when the "state" field changes to "Delivered." For other "state" field values it should not capture the&amp;nbsp;"u_enroll_date".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code :&lt;/P&gt;&lt;P&gt;var Req = current.state;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;if (Req == 'delivered' || Req == 'Delivered')&lt;/STRONG&gt;&lt;/FONT&gt; {&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //// This condition is not working.&amp;nbsp;&lt;BR /&gt;createMetric();&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;function createMetric() {&lt;BR /&gt;var mi = new MetricInstance(definition, current);&lt;BR /&gt;var gr = mi.getNewRecord();&lt;BR /&gt;gr.value=current.sys_updated_by;&lt;BR /&gt;gr.insert();&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The Condition in RED above is not working. It is creating record in metric every time the state is changes. It should capture only when the state is Ordered.&lt;/P&gt;&lt;P&gt;How to achieve it through metric script. I cannot add this condition to metric definition business rule since it is required for some other fields as well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jan 2024 05:18:15 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/metric-definition-should-execute-based-on-condition/m-p/2789040#M511436</guid>
      <dc:creator>Asmita7</dc:creator>
      <dc:date>2024-01-16T05:18:15Z</dc:date>
    </item>
    <item>
      <title>Re: Metric definition should execute based on condition</title>
      <link>https://www.servicenow.com/community/itsm-forum/metric-definition-should-execute-based-on-condition/m-p/2789052#M511437</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/413795"&gt;@Asmita7&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Did you try any code ? If yes please share so that we can help you. More you try handson, more quickly you learn.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2024 11:26:39 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/metric-definition-should-execute-based-on-condition/m-p/2789052#M511437</guid>
      <dc:creator>Dr Atul G- LNG</dc:creator>
      <dc:date>2024-01-11T11:26:39Z</dc:date>
    </item>
    <item>
      <title>Re: Metric definition should execute based on condition</title>
      <link>https://www.servicenow.com/community/itsm-forum/metric-definition-should-execute-based-on-condition/m-p/2789083#M511441</link>
      <description>&lt;P&gt;Hi Atul,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your reply and your YouTube channel.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have added the code in my question. Please suggest.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2024 11:41:24 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/metric-definition-should-execute-based-on-condition/m-p/2789083#M511441</guid>
      <dc:creator>Asmita7</dc:creator>
      <dc:date>2024-01-11T11:41:24Z</dc:date>
    </item>
    <item>
      <title>Re: Metric definition should execute based on condition</title>
      <link>https://www.servicenow.com/community/itsm-forum/metric-definition-should-execute-based-on-condition/m-p/2789150#M511445</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/413795"&gt;@Asmita7&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.servicenow.com/community/developer-forum/incident-quot-assigned-to-quot-metric-by-quot-state-quot/m-p/2014938" target="_blank"&gt;https://www.servicenow.com/community/developer-forum/incident-quot-assigned-to-quot-metric-by-quot-state-quot/m-p/2014938&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Some baseline info.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/125082"&gt;@Anurag Tripathi&lt;/a&gt;&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/265966"&gt;@Ankur Bawiskar&lt;/a&gt;&amp;nbsp; support here.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2024 12:30:01 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/metric-definition-should-execute-based-on-condition/m-p/2789150#M511445</guid>
      <dc:creator>Dr Atul G- LNG</dc:creator>
      <dc:date>2024-01-11T12:30:01Z</dc:date>
    </item>
  </channel>
</rss>

