- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2023 10:25 AM
Hello Developers,
I have a requirement that. Request type need to based on requested for's role /job title.
Please help me to finish this requiremement.
Thanks.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2023 07:31 PM
@Raj12341 Do you have any further questions on this topic, if not then please mark this answer as solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2023 11:37 AM
@Raj12341 In order to update the value of Request type field based on the Requested for's role/job title, you need to create an onChange Client script on your catalog item and a script include which will fetch the role/job title of the requestor.
Here is the sample code for onChange client script.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
var myUtils = new GlideAjax('HRUtils');
myUtils.addParam('sysparm_name', 'getRequestType');
myUtils.addParam('sysparm_requested_for', g_form.getValue('requested_for'));
myUtils.getXML(getRequestTypeResponse);
function getRequestTypeResponse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
g_form.setValue('request_type', answer);
}
}
Here is the server side script for script include, make sure to check client callable checkbox to check on the script incldue
var HRUtils = Class.create();
HRUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getSubjectPersonForHRTask: function() {
var requestedSys_id = this.getParameter('sysparm_requested_for');
var glideJobTitle = new GlideRecord('<Name of table where title is stored>');
glideJobTitle.addQuery('user',requestedSys_id);
var requestType = '';
if (glideJobTitle.next) {
if(glideJobTitle.role=='manager'){
requestType= '<set request type for manager her>'
}
//Add similar condition here
}
return requestType;
},
type: 'HRUtils'
});

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2023 07:31 PM
@Raj12341 Do you have any further questions on this topic, if not then please mark this answer as solution.