Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Use Case

ShraddhaM475477
Tera Contributor

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?

1 ACCEPTED SOLUTION

Sid_Takali
Kilo Patron

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');

View solution in original post

2 REPLIES 2

Sid_Takali
Kilo Patron

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');

souravpradh
Tera Contributor

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'
});