Unable to see details on fields in service portal
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-25-2024 06:00 AM - edited ‎10-25-2024 06:20 AM
Hi friends,
i am unable to see user related details in service portal, i am able to see in back end. Attached screen shots for reference. we have one script include (Global) and On change client script in (Hr application), i have added bothe script screen shots as well. Please assist me why this happens.
Service portal:
var sampleUtils = Class.create();
sampleUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getUserInfo: function() {
// Log the incoming parameter
var userId = this.getParameter('sysparm_userId');
if (!userId) {
gs.error('No userId provided');
return JSON.stringify({ error: 'Invalid or missing userId' });
}
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id', userId);
gr.query();
var jsonObj = {};
if (gr.next()) {
// Extract and log the values
jsonObj.title = gr.getDisplayValue('title');
jsonObj.manager = gr.getDisplayValue('manager');
jsonObj.department = gr.getDisplayValue('department');
jsonObj.location = gr.getDisplayValue('location');
} else {
gs.error('User not found with sys_id: ' + userId);
return JSON.stringify({ error: 'User not found' });
}
// Return the user details as JSON
return JSON.stringify(jsonObj);
},
type: 'sampleUtils'
});
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var userSysId = g_form.getValue('employee');
if (userSysId) {
var ga = new GlideAjax('global.sampleUtils ');
ga.addParam('sysparm_name', 'getUserInfo');
ga.addParam('sysparm_userId', userSysId);
ga.getXML(callback);
}
function callback(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
var returneddata = JSON.parse(answer);
g_form.setValue("employee_title", returneddata.title);
g_form.setValue("employee_department", returneddata.department );
g_form.setValue("employee_manager", returneddata.manager);
g_form.setValue("employee_location", returneddata.location);
}
}
0 REPLIES 0