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

Vishal Birajdar
Giga Sage

Hello @yardenKrispel 

 

Find the screenshot below.

You can create new UI action on incident table.

 

VishalBirajdar7_0-1694091042445.png

 

 

function assignToMe(){

var assignedTo = g_form.getValue('assigned_to');

if(!assignedTo){

    g_form.setValue('assigned_to', g_user.userID);
// you can set the assignment group as well
    gsftSubmit(null, g_form.getFormElement(), 'assign_to_me'); //MUST call the 'Action name' set in this UI Action

}

if (typeof window == 'undefined') {
    updateRecord();
}
function updateRecord(){
    current.update();

}

}

 

 

Vishal Birajdar
ServiceNow Developer

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

To hide UI action depend upon condition check this community link :

 

Vishal Birajdar
ServiceNow Developer

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

Thank you! The 'Assign To' functionality now works as intended. However, I am still facing an issue with automatically populating the 'Assignment Group' field.

@yardenKrispel 

 

can you send the screenshot of your code...!!

 

May be for group you need to pass sys_id of that group

 

Vishal Birajdar
ServiceNow Developer

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