Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Access Control List read records Created By User

tharzarob
Kilo Explorer

How do I set the read ACL on a table to only allow users to read records that they have created?   I have been trying to add the following conditions without luck

Created By is javascript.gs.getUserName() OR Created By is empty

I am working in the Geneva instance.

1 ACCEPTED SOLUTION

I THOUGHT SO!!! t! It's not in the wiki, it's on the developer API site.



Best practice is to use conditions before scripts, so...



Created by | is | javascript:gs.getUserName()


View solution in original post

13 REPLIES 13

We're all wrong! Abhinay is right in that it's a string, not a sys_id.



It's the user's login name, not their email. gs.getUser() doesn't have a method to return the user_name field.



You'd have to write your own little script include:


Name: getMyUserName


function getMyUserName() {


        var u = new GlideRecord('sys_user');


        if (u.get(gs.getUserID())


                  return u.user_name;


        return;


}



and call it with



Created By | is | javascript:getMyUserName()


Hi Chuck,



I think it's not required as we already have OOTB one gs.getUserName()


I THOUGHT SO!!! t! It's not in the wiki, it's on the developer API site.



Best practice is to use conditions before scripts, so...



Created by | is | javascript:gs.getUserName()


I believe it is there on the wiki too.


It is mentioned in WIKI Do I get bonus points


GlideSystem - ServiceNow Wiki