Condition to check if requestor and updated by are different users

Sofija
Giga Expert

Hi All,

I am trying to write a simple condition to check if request.requested for and opened are different (not the same user) in order to prevent issuing some email notifications when the requestor updates a ticket him/herself.

Condition that didn't work:

1. answer = (current.request.requested_for.user_name.getDisplayValue() != current.updated_by);

2. answer = (current.request.requested_for.user_name != current.updated_by);

3. answer = (current.request.requested_for != current.updated_by);

4. answer = (request.requested_for != current.updated_by);

What am I missing? Does anyone have ideas on how to do this?

Kind regards,

Kamile

1 ACCEPTED SOLUTION

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hey Kamile,



This should work


answer = (current.request.requested_for.user_name != current.sys_updated_by);



Correction : updated_by is not the right column name and it should be sys_updated_by.



I hope this answers your question


View solution in original post

3 REPLIES 3

ghsrikanth
Tera Guru

Line 3 and 4 wont work because left hand side result is a 32 bit sys_id and right hand side result is a string.


In case 1 and 2, mostly it looks like it will work, but have a concern about when the updated_by field will be updated?



I presume its a business rule on the table


you can write the condition as -


current.request.requested_for != gs.getUserID(); //considering most of the updates happens through interactive session



Now any triggers happens on the record, it will compare the logged in user and compare with requested for


For debug purpose, could you please print these values   before the comparision-


gs.log('Requested for: ' + current.request.requested_for, 'debugNotif');


gs.log('User Logged: ' + gs.getUserID(), 'debugNotif');


answer = (current.request.requested_for != gs.getUserID());




Hopefully it should help


Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hey Kamile,



This should work


answer = (current.request.requested_for.user_name != current.sys_updated_by);



Correction : updated_by is not the right column name and it should be sys_updated_by.



I hope this answers your question


This one worked perfectly. And thank you for the correction that I should of used sys_updated_by not just updated_by