- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2024 11:21 PM
If there is a custom field on click of UI action I want to populate count of incident which are from same assignment group and I want to show this field to only admin or ITIL user which modules you will use for this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2024 11:06 AM
Hi @ShraddhaM475477 You can try to create a Read ACL on the count field and use below script in advanced condition
answer = gs.hasRole('admin') || gs.hasRole('itil');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2024 11:06 AM
Hi @ShraddhaM475477 You can try to create a Read ACL on the count field and use below script in advanced condition
answer = gs.hasRole('admin') || gs.hasRole('itil');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
create a Client UI Action that calls a Server-side Script Include to fetch the count. Use a Read ACL to restrict field visibility and a UI Policy to hide it on the form.
Client UI Action:
Condition:
gs.hasRole('admin') || gs.hasRole('itil');
function calculateIncidents() {
var group = g_form.getValue('assignment_group');
if (!group) {
alert('Please select an Assignment Group first.');
return;
}
// GlideAjax to get count from server
var ga = new GlideAjax('IncidentCountAjax');
ga.addParam('sysparm_name', 'getSameGroupCount');
ga.addParam('sysparm_group', group);
ga.getXMLAnswer(function(answer) {
g_form.setValue('u_same_group_count', answer);
});
}
Script Include:
var IncidentCountAjax = Class.create();
IncidentCountAjax.prototype = Object.extendsObject(AbstractScriptInclude, {
getSameGroupCount: function() {
var group = this.getParameter('sysparm_group');
var count = 0;
var gr = new GlideRecord('incident');
gr.addQuery('assignment_group', group);
gr.addQuery('active', true); // Optional: Count only active
gr.query();
return gr.getRowCount();
},
type: 'IncidentCountAjax'
});
