Capture hr service, transffered to, transffered from in Metric defination
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2023 12:42 AM
Hi All,
I have a requirement for HR case transfer, where i wanted to see how much time a HR case has spent in one HR service.
I have created 3 metric definitions one for Field = HR service, Transferred to and transferred from. Attaching the screenshot for reference.
Problem - I am not getting any input in metric definition, i created a new case after creating the metric definition and transferred multiple cases, multiple time. Ran lot of testing too.
Please suggest how can i achieve that?
Thanks in Advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2023 12:51 AM
Hi @Prateek07 ,
Please create a business rule on your HR case table which should be a "After" Insert,Update & Delete
queueMetricUpdate();
function queueMetricUpdate() {
var gru = new GlideScriptRecordUtil.get(current);
var fieldsChanged = gru.getChangedFieldNames();
var gr = getDefinitions(fieldsChanged);
fields = '';
while (gr.next())
fields += gr.field + ',';
if (fields.length > 0) {
fields = '[' + fields.substring(0, fields.length - 1) + ']';
gs.eventQueue('metric.update', current, fields, current.sys_mod_count, 'metric_update');
}
}
function getDefinitions(fields) {
var gr = new GlideAggregate('metric_definition');
gr.addActiveQuery();
var tables = GlideDBObjectManager.getTables(current.getTableName());
gr.addQuery('table', tables);
gr.addQuery('field', fields);
gr.groupBy('field');
gr.query();
return gr;
}
Please create this n test it should work.
Thanks,
Danish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2023 01:04 AM
@Danish Bhairag2 do i need to create the BR in global or in Human Resources: Core application?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2023 01:06 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2023 01:24 AM
I am getting an error after submitting the case and it is not captured in metric definitions.
"GlideScriptRecordUtil is not allowed in scoped applications"
do i need to mention the field names in script or it can be blank as well?
var gr = getDefinitions(fieldsChanged); fields = '';
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2023 01:25 AM - edited ‎10-23-2023 01:26 AM
M so sorry I have created this in Global so never faced this. Could u please create it in a global scope n check. Apologies for the rework.
In script u don't need to add or modify anything
Thanks,
Danish