How to control the visibility of a record producer based on current logged in users location

kbanerje
Mega Guru

Hi All,

Can you guys sight a piece of code which needs to be incorporated for the below logic.

We have a Category under which we have an array of record producers for one among the list I need to control the visibility of tehj full item based on current logged in users location.

For e.g if current logged in users location(reference field) in his user profile is "xyz" then it will show that RP else not.

Kind Regards,

Kiritman

4 REPLIES 4

shaikbasha
Kilo Expert

var userID = g_user.userID;



var userRecord = new GlideRecord('sys_user');


userRecord.addQuery('sys_id',userID);


userRecord.query();


if(userRecord.next())


{



var location = userRecord.location;


}



The above code will give you the Location of logged user.


Hope this helps you.



Thank you.


Thanks but you have not added the condition in the code for the location to control visibility of the record producer item and where can I write this code to control the visibility of the record   producer.


Mihir Mohanta
Kilo Sage

Hi Kirtiman,



1.You have to define a user criteria for this.Add location in the Locations field of user criteria.



find_real_file.png



2.Go to the Service catalog -->Record producers and open the record producer.Add the user criteria in the Available for related list.



find_real_file.png




Please go through below link for your reference.


User Criteria - ServiceNow Wiki




Thanks,


Mihir


Thanks Mihir it was helpful though I found actual solution is OOB and we have related list available to location where we just have to add the location that's it.No need to create user criteria.