1 Reply · Latest reply on Nov 27, 2017 12:13 AM by Gaurav Bajaj

    Metric definition only for specific catalog tasks

      Hi,

       

      We have a requirement where metric should be run only for particular catalog tasks and not for all

       

      We have defined a metric on catalog task table and state field, but metric instances are getting created for all catalog task. It should be restricted to specific catalog tasks.

       

      I understood that it might be possible if we can select metric definition type is "Script calculation", but it is not populating metric instance start and end dates

       

      Kindly help with the same asap?

       

      Please find the below script

       

      if (current.request_item.cat_item == '19e92739db4f7e00172bb6bffe9619ed'){

        createMetric();

      }

       

       

      function createMetric() {

        var mi = new MetricInstance(definition, current);

        if (mi.metricExists())

        return;

       

        var gr = mi.getNewRecord();

        gr.value = current.state;

         // How to set metric start and end dates and also duration

        gr.calculation_complete = true;

        gr.insert();

      }

       

      Thanks,

      Pavan