In CSM Contacts having views ( like Case, Customer Self Service etc ). How to identify user currently selected view in Contacts through Rest API ( for example, if user currently using the "Customer Self Service". I need to know the customer exact selected view ).
Please provide detailed information. Otherwise please suggest alternate method for this. It will helpful for us.Thanks!
find reference SS,
The table you want to query is sys_user_preference
.
The preference you are querying for is: <table_name>_list.view
- I'm not sure what the internal name of the Contacts table is (try "contact"), but for the Incidents table it's "incident", so I'll show you with that.
Do a REST API to:
https://your-instance.service-now.com/api/now/table/sys_user_preference?sysparm_query=name=incident_list.view
You should get a response back with a JSON body. If you use the key result[0].value
you should find the display name of the view. Note that this only works if the API is being executed by the user who wants to know their own preference.
Alternatively, you could create a scripted REST API which uses the following JS to find their preference:
var user = gs.getUser(); // get our user object
user = gs.getUserById('<their sys id>'); // get the user object we want the preference of
var pref = user.getPreference('incident_list.view');
return pref;
This would have to be executed by a user with permission to read the requested user's permission, however.