What is the right approach to get the details of the current logged in users in the ServiceNow at client script?
Assuming the database name of the ServiceType field is "u_servicetype", this should work: var gr = new GlideRecord('sys_user');
gr.get(g_user.userID);
var svcType = gr.u_serviceType;
Note that this might have a slight UI delay since gr.get is doing synchronous AJAX call. You can do it asynchronously with a gr.query and a callback function, as:
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id',g_user.userID);
gr.query(function(user){
if(user.u_servicetype=="CMS"){
return;
} else {
// all the rest of your code...
}
});
BY Best Interview Question ON 26 Nov 2020