Trigger Metric Definition from Business Rule

Ricky S Larsson
Tera Guru

I have a Metric Definition that creates a Metric when the Additional Comments field is changed: An agent writes a comment and a metric check the time from when the ticket is created until someone wrote a comment.

Now I also need to trigger this Definition when someone writes a Close Note. I need to trigger the same definition, so I can't create a new Definition. Problem is, only one field can be tracked in a Metric Definition.

The beginning of the Metric Definition script looks like this:

if (new SFGAdditionalComments().isAssignmentGroupMember(current.sys_id, current.assignment_group)) {
	createMetric();
}

function createMetric()

// The rest of the code is the function

My idea is to create a Business Rule that would trigger this Definition, or specifically trigger the createMetric() function (To bypass the If statement)

How would I write my Business Rule to do just that?

1 ACCEPTED SOLUTION

I wrote it exactly like you wrote. The last parameter just went down one line in my post so it seemed like it was missing.

But I found the solution to this problem: The field needs to be inside of [ ] brackets

The problem was that I wrote 'comments' instead of '[comments]'

This line of code works:

gs.eventQueue('metric.update', current, '[comments]', current.sys_mod_count, 'metric_update');

 

Thank you for pointing me in the right direction!

View solution in original post

6 REPLIES 6

Ananth Reddy
Tera Contributor

Hi,

 

You mentioned that you have the Metric Definition that creates a Metric when the Additional Comments field is changed: An agent writes a comment and a metric check the time from when the ticket is created until someone wrote a comment. I also have the same requirement that - I need to have a Metric definition which checks the time between ticket created and first Additional comment (i.e., someone wrote a first comment in Additional comments field). Can you please help me with the metric definition configuration?

amartin216
Tera Contributor

Hello!
I have applied another solution. In the metric definition via script I search if a metric exists for the current metric definition and incidence, and I do the following:
If it doesn't exist, I create a new metric with the value ‘Group name’+separator. E.g Service Desk‘->’.
If only one metric exists for the incident, I check if the end of the value is equal to the separator, in this case I concatenate the new group name in the value field and update the metric. E.g Service Desk‘->’Software
For the other cases I take the name of the last group of the previous metric and concatenate the separator and the name of the new group E.g. Software‘->’Network.

Best regards