ACL help for current logged in User

ServiceNow SA
Kilo Guru

I am having issue in ACL.

I want a checkbox field in user table to be edited only by the user who's profile it is. Nobody else has the right to edit that field. For eg. I can make check/uncheck that field in my user profile. Nobody else can do.

I have written a script but that is not working. Can anybody help me on that.

1 ACCEPTED SOLUTION

Hi Sri,



you are comparing user_name with current.sys_id in below line


us.addQuery('user_name', current.sys_id);



This won't work since current.sys_id will give you sys_id and user_name field in user table has user name


use this


gs.getUserName()in place of current_sys_id.



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

8 REPLIES 8

var us = new GlideRecord('sys_user');


us.addQuery('sys_id', gs.getUserID());


us.query();


if (us.next()){


    answer = true;


}


else


    answer = false;


Robert Duca
Tera Contributor

Use this... it should work fine:

if (gs.getUserID() == current.sys_id)
answer = true;
else
answer = false;

Ankur Bawiskar
Tera Patron
Tera Patron

@ServiceNow SA 

Hope you are doing good.

Let me know if I have answered your question.

If so, please mark appropriate answer as correct & helpful to close the thread.

If not, please let us know if you need some more assistance.

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Ankur Bawiskar
Tera Patron
Tera Patron

@ServiceNow SA 

Hope you are doing good.

Did my reply answer your question?

If so, please mark it correct so that the question will appear as resolved for others who may have a similar question in the future.

Thanks!
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader