The CreatorCon Call for Content is officially open! Get started here.

'Assign To Me' button in Incident and catalog task and population of assignment group

Amith3
Kilo Contributor

Hello All,

I have a requirement to add 'Assign To Me' button/UI Action in Incident and catalog task. But the button should be available to all, regardless of where the ticket is assigned. For example – I get an email \ call \ Skype asking to look at a ticket assigned to SAP team. I then read the details and I can fix it. So I click “Assign to me” button and pick up the call.

In short, whatever the group the ticket is assigned to, if i click on 'Assign To Me', it should get assigned to My Assignment Group and then to me.

Our system is set like an Incident is assigned to one Group automatically based on the 'IT Service/Business Service' user selection in the ticket and then the support person who is a part of that group can assign to his/her name. 

So how to implement the 'Assign To Me' button here? My view is if I click on the 'Assign To Me' button, the ticket should assign to me , if i am part of the group in which the ticket is Assigned. Else if i am not part of that group, a message should come 'You are not part of the group, Please select the correct assignment group' clearing and making the 'Assignment Group' selection field as mandatory (and also it should list the groups which i am part of).

Is that possible? If yes, could you please help with the details/code?

find_real_file.png

17 REPLIES 17

Hi Ankur,

We tried creating UI Action and UI Page (for multiple groups; which would show groups to which users belongs), but the group selection is showing all the groups and not the user's groups.

Script of UI Action (Assign To Me):

function popTW() {

var gDialog = new GlideDialogWindow('time_worked_entry');

var cgroup = g_form.getValue('assignment_group');

gDialog.setPreference('cgroup', cgroup);

gDialog.setTitle('Choose the assignment group');

gDialog.render();

}

 

Script of UI Page named time_worked_entry:

<?xml version="1.0" encoding="utf-8" ?>

<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">

<form>
<g:evaluate>
var query = '';
var usr = gs.getUserID();
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('user',usr);
gr.query();
while(gr.next()){
query=sys_idIN+gr.group;
}
</g:evaluate>

<g:evaluate var="jvar_cgroup"

expression="RP.getWindowProperties().get('cgroup')" />

<span>Choose the appropriate assignment group from the list to assign the incident to yourself.</span><br/>

<table width="580">

<tr>

<td nowrap="true"> ${gs.getMessage('Assignment Group')}: </td>

<td>

<g:ui_reference name="assignment_group" id="assignment_group" table="sys_user_group" query= "${query}"/>

</td>

</tr>
<tr>
<td>
<br></br>
</td>
</tr>

<tr id="dialogbuttons">

<td align="right" colspan="2">

<g:dialog_buttons_ok_cancel ok="return onSubmit();" cancel="return onCancel();"/>

</td>

</tr>

</table>

</form>

</j:jelly>

 

Any idea why it is not showing?

 

Thanks and Regards,

Amith.

updated line. 

 

<g:evaluate>
var query = '';
var usr = gs.getUserID();
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('user',usr);
gr.query();
while(gr.next()){
query='sys_idIN'+gr.group;
}

Hi Amith,

please find updated code to show groups; you need to show them with some radio buttons so that you can select those values

As of now I have just kept them in table tag

<?xml version="1.0" encoding="utf-8" ?>

<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">

<g:evaluate object="true" var="jvar_groups">
var query = '';
var usr = gs.getUserID();
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('user',usr);
gr.query();

gr;
</g:evaluate>

<span>Choose the appropriate assignment group from the list to assign the incident to yourself.</span><br/>

<table width="580">

<tr>

<td nowrap="true"> ${gs.getMessage('Assignment Group')}: </td>

<td>

<j:while test="${jvar_groups.next()}">

<tr>

<td>${jvar_groups.group.name}</td>

</tr>

</j:while>

<tr id="dialogbuttons">

<td align="right" colspan="2">

<g:dialog_buttons_ok_cancel ok="return onSubmit();" cancel="return onCancel();"/>

</td>

</tr>

</table>

</form>

</j:jelly>

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader