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

Brad Tilton
ServiceNow Employee
ServiceNow Employee

Depends on exactly how you're doing this, but I think you would have to use gs.getUserID() as it returns a sysid rather than an object.


I didn't notice a difference switching to the getUserID() call. The behavior is the same, with the "Assignment group" getting set to Database, and the user still blank. Is there maybe another way to specify a dynamic entry for user?


Screen Shot 2014-09-16 at 3.20.21 PM.JPG


I would try adding javascript:gs.getUserID(); to the User field.


I tried adding the javascript:gs.getUserID(); to the User's field dictionary as the default value, but the behavior still doesn't change. I'm wondering if there's something different about the User field for Assignment rules?