Hide a speciifc HR service in Transfer Case

Srinath S
Tera Contributor

Hi Everyone,

I want to hide a certain HR service in the Transfer Case, both in Native UI and HR Agent Workspace.

Any help is appreciated.

 

Thanks,

Srinath 

1 ACCEPTED SOLUTION

@Srinath S @Emi Nem 

Ah! my bad I forgot to share the solution for HR Agent Workspace. 

 

Caution: In order to achieve the same functionality on HR Agent workspace, you need to make some changes within an OOTB script include hr_CaseTransferAjax. Any changes here would mean you would need to take care of any changes during upgrades by manually merging them in this script include.

 

For now let's proceed with how this can be achieved in workspace.

 

When we closely look at the workspace client script for Transfer case UI Action we find the following.

Screenshot 2023-04-10 at 3.19.11 PM.png

This UI Action calls an OOTB script include hr_CaseTransferAjax to fetch the possible list of services. When we further drill down in this script include we find a method 

_getServices: function(subjectPerson) { on line number 44, which actually returns the list of services. 
 
This is actually the place where you need to make the changes.
Screenshot 2023-04-10 at 3.25.00 PM.png

On line number 45, replace the existing line with the following.

var oldServices = new sn_hr_core.hr_CaseCreation().getServicesForUser(subjectPerson || '', true);
var services = new sn_hr_core.HRServiceV2().getUpdatedHRServices(oldServices);

rest of the code should remain intact.

Screenshot 2023-04-10 at 3.08.37 PM.png

Save the changes and test it on workspace this time the excluded services will not appear.

 

This is how the service dropdown look when the "HR Accounts Inquiry" service is not exlcuded.

Screenshot 2023-04-10 at 3.07.23 PM.png

 

This is how it looks when it is excluded.

Screenshot 2023-04-10 at 3.12.14 PM.png

Hope finally this help you achieve your goal.

View solution in original post

12 REPLIES 12

Srinath S
Tera Contributor

Hi Sandeep,

Can you please instruct me from which line I have to add the query?

Thanks,

Srinath

You need to put the HR service check after line number 21.

 

The recommend way would be to define system property of a comma separated list of sys_ids of those HR services which you do not wish to be a part of the New HR service drop down.

 

You can access the property on line 22 like the following.

 

var excludedHRServices = gs.getProperty('excluded.hr.services');

var excludedHRServiceArray = excludedHRServices.split(',');

var sysId = RP.getParameterValue('sysparm_predicted_value');
if(excludedHRServiceArray.indexOf(sysId)==-1){
      
var gr = new GlideRecord('sn_hr_core_service');
var displayValue;
if(gr.get(sysId)){
displayValue = gr.name;
}
displayValue;
}
 Hope this helps.

Hi Sandeep,

I created a system property for excluding a HR service and used your above query but still I am able to find the HR Service in the transfer case's "New HR service" dropdown. I'm attaching the newly created System Property and modified UI page for transfer case. Please let me know if you can find any errors.

EmiNem_0-1680878741795.png

 

Thanks,

Srinath

Hi Sandeep,

I created a new system property and modified the transfer case UI page using your above query. But, still I am able to see the HR service that I want to hide in the transfer case's "New HR Service" dropdown. I am attaching the screenshots of newly created System property and modified transfer case UI page. Please let me know if you spot any errors.

SrinathS_0-1680879164649.png

The above image is the modified transfer case UI page.

 

Thanks,

Srinath