Hide logged on user from user selection reference field

Floridalife
Giga Expert

I've added this reference qual condition to filter out the currently logged on name from the user selection field on a request form, however that doesnt work, any idea?

2016-06-09 10_34_19-ServiceNow.png

1 ACCEPTED SOLUTION

Chuck Tomasi
Tera Patron

OK, I thought it would work, but after some testing - no such luck. I also tried a dynamic filter. Nothing there because it only does equality (like "Me" is simply gs.getUserID())



So what I came up with was this:


  • Simple script include named myRefQual
    • function myRefQual() {
            return 'roles!=admin^regionISNOTEMPTY^....^sys_id!=' + gs.getUserID();}
  • Change the reference qualifier to advanced and call the script include
    • javascript:myRefQual()

If you change your reference qualifier from simple to advanced, it will translate everything you have right now to an encoded query string that you can use in your script include.


View solution in original post

4 REPLIES 4

Chuck Tomasi
Tera Patron

User ID is a string field. You want to use sys_id to compare against javascript:gs.getUserID();


Chuck Tomasi
Tera Patron

OK, I thought it would work, but after some testing - no such luck. I also tried a dynamic filter. Nothing there because it only does equality (like "Me" is simply gs.getUserID())



So what I came up with was this:


  • Simple script include named myRefQual
    • function myRefQual() {
            return 'roles!=admin^regionISNOTEMPTY^....^sys_id!=' + gs.getUserID();}
  • Change the reference qualifier to advanced and call the script include
    • javascript:myRefQual()

If you change your reference qualifier from simple to advanced, it will translate everything you have right now to an encoded query string that you can use in your script include.


That worked thank you ! my final script include ended up being



function myRefQual() {


      return 'roles!=admin^u_region!=^user_nameNOT LIKEadmin^active=true^sys_id!=' + gs.getUserID();}


Perfect. That's what I was aiming for. Couldn't recall all the details. Glad you go ti working.