Issue in updating value of Metric instance

sagarikamodiam
Tera Contributor

Hi All,

I have a scenario for Metric definitions where in metric definition script it checks if record is existing or not and if record exists it should update the new value of that particular field into the existing metric instance value instead of creating a new record in instance table. I have tried the following script but it is not updating metric instance values. Hope some body can help me out with this.

 

(function evaluateMetric(current, definition) {

              var grMetric = new GlideRecord('metric_instance');

    grMetric.addQuery('id', current.getUniqueValue());

    grMetric.addQuery('definition', definition.getUniqueValue());

    grMetric.query();

   

    if (grMetric.next()) {

                             grMetric.field_value = current.getValue('assignment_group');

    grMetric.value = current.getDisplayValue('assignment_group');

             

                             grMetric.update();

              }

                             })(current, definition);

1 REPLY 1

Arnoud Kooi
ServiceNow Employee
ServiceNow Employee

Probably BR: metrics instance - set display value prevents updating the display value.

Try adding: grMetric.setWorkflow(false); before the update.