- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-04-2024 01:36 AM - edited ‎01-04-2024 07:44 AM
Hi All,
Based on the condition option will be visible to the select box, wrote onload catalog client script & script include. ut its not working properly.
Script Include:
var CountrySubjectPerson = Class.create();
CountrySubjectPerson.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
checkemp: function(){
var SubjectPerson = this.getParameter('SubPerson');
var userRec = new GlideRecord('sys_user');
userRec.get(SubjectPerson);
var userALPSID = userRec.user_name;
var hrRec = new GlideRecord('sn_hr_core_profile');
hrRec.addQuery('employee_number',userALPSID);
hrRec.addEncodedQuery('u_contry=IN^user.u_consent_status=accepted^user.u_employee_type=INTERNAL^NQu_countryISEMPTY^user.u_consent_status=accepted^user.u_employee_type=INTERNAL^user.location.country=IN');
hrRec.query();
while(hrRec.next()){
return 'Yes';
}
},
type: 'CountrySubjectPerson'
});
onload catalog client script:
function onLoad() {
//Type appropriate comment here, and begin script below
//g_form.addInfoMessage(subject_person);
var emp = g_form.getValue('subject_person');
var empcheck = new GlideAjax('sn_hr_core.CountrySubjectPerson');
empcheck.addParam('sysparm_name', 'checkemp');
empcheck.addParam('SubPerson',emp);
empcheck.getXML(getCountryValue);
alert('Inside elseif');
}
function getCountryValue(response) {
var EmpCountry = response.responseXML.documentElement.getAttribute("answer");
g_form.addInfoMessage(EmpCountry);
if(EmpCountry == 'Yes')
{
g_form.addInfoMessage('inside emp country');
g_form.clearOptions('please_select');
g_form.addOption('please_select','',"-- None --");
g_form.addOption('please_select_the_type_of_absence','Maternity,'Maternity');
}
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-04-2024 02:17 AM
@abirakundu23 Please update your script include as follows.
var CountrySubjectPerson = Class.create();
CountrySubjectPerson.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
checkemp: function(){
var SubjectPerson = this.getParameter('SubPerson');
var userRec = new GlideRecord('sys_user');
userRec.get(SubjectPerson);
var userALPSID = userRec.user_name;
var hrRec = new GlideRecord('sn_hr_core_profile');
hrRec.addQuery('employee_number',userALPSID);
hrRec.addEncodedQuery('u_contractual_country=Canada^user.u_consent_status=accepted^user.u_employee_type=INTERNAL^NQu_contractual_countryISEMPTY^user.u_consent_status=accepted^user.u_employee_type=INTERNAL^user.location.country=Canada');
hrRec.query();
if(hrRec.next()){
return 'Yes';
}
},
type: 'CountrySubjectPerson'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-04-2024 02:10 AM - edited ‎01-04-2024 02:16 AM
Hi @abirakundu23
In your server script instead of WHILE replace it with IF.
Secondly, are you getting "g_form.addInfoMessage(EmpCountry);" as Yes ?
Also in your onLoad CS the variable name is different, please check.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-04-2024 02:17 AM
@abirakundu23 Please update your script include as follows.
var CountrySubjectPerson = Class.create();
CountrySubjectPerson.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
checkemp: function(){
var SubjectPerson = this.getParameter('SubPerson');
var userRec = new GlideRecord('sys_user');
userRec.get(SubjectPerson);
var userALPSID = userRec.user_name;
var hrRec = new GlideRecord('sn_hr_core_profile');
hrRec.addQuery('employee_number',userALPSID);
hrRec.addEncodedQuery('u_contractual_country=Canada^user.u_consent_status=accepted^user.u_employee_type=INTERNAL^NQu_contractual_countryISEMPTY^user.u_consent_status=accepted^user.u_employee_type=INTERNAL^user.location.country=Canada');
hrRec.query();
if(hrRec.next()){
return 'Yes';
}
},
type: 'CountrySubjectPerson'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-04-2024 02:41 AM - edited ‎01-18-2024 06:09 AM
hi @Sandeep Rajput,
I checked it seems working.
hi @_Gaurav ,
Yes info message display & changed to if. still its not working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-04-2024 08:07 AM
@abirakundu23 Can you check the scope of the SI?