Question on Script include
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
5 hours ago
I wrote a script include in Employee center core and a client script in the same application for a record producer.
There I have a requirement to check if Requested for is a member of HR groups or not.
I created a field and marking it based on the script include and client script
Client script
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading)
return;
// If requested_for is cleared
if (!newValue) {
g_form.setValue('requested_for_is_member_of_hrops', 'false');
return;
}
var hrOpsGroup = 'de66fff31b263614454e0ed3604bcbfb';
var ga = new GlideAjax('CheckGroupMembership');
ga.addParam('sysparm_name', 'isUserInGroup');
ga.addParam('sysparm_user', newValue);
ga.addParam('sysparm_group', hrOpsGroup);
ga.getXMLAnswer(function(answer) {
if (answer === 'true') {
g_form.setValue('requested_for_is_member_of_hrops', 'true');
} else {
g_form.setValue('requested_for_is_member_of_hrops', 'false');
}
// Optional debug
alert('HR Ops Member: ' + answer);
});
}
Script include:
Any help is highly appreciated.
Thank yoU!
Script include:
var CheckGroupMembership = Class.create();
CheckGroupMembership.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
isUserInGroup: function() {
var userId = this.getParameter('sysparm_user');
var groupId = this.getParameter('sysparm_group');
if (!userId || !groupId)
return 'false';
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('user', userId);
gr.addQuery('group', groupId);
gr.query();
return gr.hasNext().toString();
}
});
ANy suggestions what I am missing?
it works but also gives an error of "ErrorThere is a JavaScript error in your browser console"
ANy suggestions what I am missing?
it works but also gives an error of "ErrorThere is a JavaScript error in your browser console"
Any help is highly appreciated.
Thank yoU!
0 REPLIES 0

