How do you set the current user to the "Assigned To" field using Assignment rules?

warren_chan
ServiceNow Employee
ServiceNow Employee

I'm using an Assignment rule to populate the "Assignment group" field, and thought I could set the "Assigned to" field to be the current user while I'm at it. I thought this would be a simple statement, like:

 

current.assigned_to = gs.getUser();

 

but this doesn't seem to be working. I can get this working with a business rule (user as Dynamic Default of "Me"), but would prefer to use an Assignment rule instead. Any ideas?

 

Thanks!

1 ACCEPTED SOLUTION

Michael Fry1
Kilo Patron

If you are going to use a Script, I don't think you can have anything populated in the User or Group fields. If you do, I think it ignores the script.   Try blanking those two fields and use something like this for your script:



current.assigned_to = gs.getUserID();


current.assignment_group.name = 'Network';



Thanks!


View solution in original post

12 REPLIES 12

This is correct. It does not like group handled in the "Assign To" tab and user handled in the "Script" tab. You can use one of those two tabs but not both.

geoffcox
Giga Guru

Beware that second line: current.assignment_group.name = 'Network'



That statement doesn't select an assignment group, it tries to change the name of the currently selected assignment_group to "Network".



However, if this is in a "before update" business rule, it will have no effect because the assignment_group object is not being updated.


Aurobindo Bhuya
Kilo Contributor

current.assigned_to = gs.getUserID();
current.update();