- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2025 04:20 AM
Hi All,
I have a custom table under custom scope on which I am trying to track durations taken by tickets to transition through different states.
Before creating metric definition on this table, I created a business in my custom scope, selected my custom table and copied script from 'metrics events' business rule which is as follows-
Has anyone faced this issue before? Can you please let me know how to resolve this issue?
Thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2025 04:43 AM
Hi @BijoyDeb ,
In scop app all predefined API wont work and support due to security reason, in your case "GlideScriptRecordUtil" can not be use in scoped application. Check this script include and modify the access, or if it is in global application then user like "global.GlideScriptRecordUtil".
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay
-------------------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2025 05:39 AM
basically you want to determine the changed fields in scoped app
use this as an alternative. I hope you are using after update BR to determine changed fields
queueMetricUpdate();
function queueMetricUpdate() {
var fields = [];
for (var key in current) {
if (!key.toString().startsWith('sys') && (current[key] != previous[key])) {
fields.push(key.toString());
}
}
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;
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2025 04:41 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2025 04:43 AM
Hi @BijoyDeb ,
In scop app all predefined API wont work and support due to security reason, in your case "GlideScriptRecordUtil" can not be use in scoped application. Check this script include and modify the access, or if it is in global application then user like "global.GlideScriptRecordUtil".
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay
-------------------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2025 06:13 AM
Hi @BijoyDeb ,
Thank you for marking my solution as helpful! The community now supports multi-solution acceptance, allowing you to accept multiple answers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2025 05:39 AM
basically you want to determine the changed fields in scoped app
use this as an alternative. I hope you are using after update BR to determine changed fields
queueMetricUpdate();
function queueMetricUpdate() {
var fields = [];
for (var key in current) {
if (!key.toString().startsWith('sys') && (current[key] != previous[key])) {
fields.push(key.toString());
}
}
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;
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader