How to compare current user with assigned to field in service now

Community Alums
Not applicable

How can I check if current user is same as assigned to user in business rule.

I have used gs.getUser().isMemberOf(current.assigned_to) and

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

But both are returning false

 

1 ACCEPTED SOLUTION

Andrew Barnes -
ServiceNow Employee
ServiceNow Employee

Greetings Sindhu21,

 The 2nd one should very much work. I have a script in use right now for - 

current.assigned_to == gs.getUserID();

The isMemberOf doesn't work because that checks group membership. Check your values with the script debugger by throwing in a break point.

-Andrew Barnes
Join me at Developer Blog

View solution in original post

5 REPLIES 5

Alberto Consonn
ServiceNow Employee
ServiceNow Employee

Hi,

You can do this in the conditions by dot-walking and the dynamic filter.

Assigned to | is (dynamic) | me

Assigned to.manager | is (dynamic) | me

Refer to To compare current logged in user and assigned to user name.

If I have answered your question, please mark my response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.

Thank you

Cheers
Alberto

Chandu12
Mega Expert

https://community.servicenow.com/community?id=community_question&sys_id=70c8c761db5cdbc01dcaf3231f961932

 

Check this and you will have a solution from Chuck

 

Mark the anaswer as correct and helpful..!!!

 

Regards,

Chalan

Chalan B L
Giga Guru

In the BR you can check the filter conditions like the below

 

find_real_file.png

 

https://community.servicenow.com/community?id=community_question&sys_id=70c8c761db5cdbc01dcaf3231f961932

 

Check this and you will have a solution from Chuck

 

Mark the answer as correct and helpful if it helped you!!!

Andrew Barnes -
ServiceNow Employee
ServiceNow Employee

Greetings Sindhu21,

 The 2nd one should very much work. I have a script in use right now for - 

current.assigned_to == gs.getUserID();

The isMemberOf doesn't work because that checks group membership. Check your values with the script debugger by throwing in a break point.

-Andrew Barnes
Join me at Developer Blog