ui action

yardenKrispel
Tera Contributor

Hi, I need to create an 'Assign to Me' button on the incident form. This button should only be visible when the 'Assign To' field is not already set to the current user, and when the current user has the 'itil' role. When clicked, the button should automatically assign the incident to the current user (in the 'Assign To' field) and set the 'Assignment Group' field to the default user group.

Thanks, Yarden

12 REPLIES 12

yardenKrispel_0-1694092459136.png

 

Ok so you need to pass "sys_id" of default group :

 

g_form.setValue('assignment_group', <sys_id>);

 

 

 

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

Action

1. Assign current user to “assigned to” field

2. Assignment group = Default user group

Ankur Bawiskar
Tera Patron
Tera Patron

@yardenKrispel 

g_user in condition field won't work and it's wrong as shared in earlier screenshots.

In the condition field you should use server side code

gs.hasRole('itil') && current.assigned_to == ''

Script:

current.assigned_to = gs.getUserID();

current.assignment_group= 'groupSysId'; // give here the group sysId

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

Hi @Ankur

 

Yeah...I thing I missed that part....!!

Thanks for correction..!!

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates