Hide HR Service from Transfer Case if agent is from Japan

Drishti
Tera Guru

Hi Community,

 

An agent from Japan, once click on Transfer Case then they should see only selected HR Services.

How can we achieve this ?

No, HR Criteria is not something we can go ahead with, as those HR Services which needs to be excluded from Transfer case list need to be available for Japan user.

 

After searching I do have received one community link "https://www.servicenow.com/community/developer-articles/exclude-hr-services-from-transfer-case-hr-se... but where exactly i should put my query to check if agent is from Japan.

 

Very much thanks in advance !

1 REPLY 1

vandanasaluja
Tera Contributor

you can write it inside the Script Include that builds the Transfer Case HR Service list

var HRTransferServiceFilter = Class.create();
HRTransferServiceFilter.prototype = {
initialize: function () {},

getEligibleServices: function () {

var services = [];
var user = gs.getUser();
var isJapanAgent = false;

// Determine if agent is from Japan
var usr = new GlideRecord('sys_user');
if (usr.get(user.getID()) && usr.location.country == 'Japan') {
isJapanAgent = true;
}

var hrService = new GlideRecord('sn_hr_core_service');
hrService.addActiveQuery();

// Apply Japan-specific filtering
if (isJapanAgent) {
hrService.addQuery('sys_id', 'IN',
'SERVICE_SYSID_1,SERVICE_SYSID_2,SERVICE_SYSID_3'
);
}

hrService.query();
while (hrService.next()) {
services.push(hrService.getUniqueValue());
}

return services;
},

type: 'HRTransferServiceFilter'
};