in servicenow , i wrote one script include and client script to get the deparmtn name of…
- User
in servicenow , i wrote one script include and client script to get the deparmtn name of current logged in user, but not working please check
function onLoad() {
codevar ajax = new GlideAjax('GetUserInfo'); ajax.addParam('sysparm_name', 'getDepartment'); ajax.addParam('sysparm_userID',g_user.userID); ajax.getXMLAnswer(function(response) { alert("Current user Deparrtment is :" + response); });}
var GetUserInfo = Class.create(); GetUserInfo.prototype = Object.extendsObject(AbstractAjaxProcessor, {
codegetDepartment: function(userID) { var user = new GlideRecord('sys_user'); if (user.get(userID)) { return user.department.name; } return "No Department Found"; }, type: 'GetUserInfo'});
- Assistant
Your script likely has a couple of issues, both in the client script and in the server-side script include. Below are suggestions for fixing them.
Client Script Corrections