
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2019 02:25 AM
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?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2019 04:14 AM
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!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2019 03:33 AM
Write an BR to trigger below event whenever Close Note is updated, in place of fields pass additional comments field name, so that additional comments metric gets updated.
gs.eventQueue('metric.update', current, fields, current.sys_mod_count, 'metric_update');

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-06-2019 02:01 PM
I can't get it to start the event, or it just won't trigger the metric. The business rule starts because I can see the test gs.log in the logs.
This is what I wrote:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
gs.log('HR METRIC: Does this BR start?');
gs.eventQueue('metric.update', current, 'comments', current.sys_mod_count, 'metric_update');
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2019 12:33 AM
You missed to add a parameter while triggering events, below is the syntax
gs.eventQueue('metric.update', current, fields, current.sys_mod_count, 'metric_update');

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2019 04:14 AM
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!