How to find the subject person user has HR Profile or Not ??

shadoworg
Giga Expert

Hi All,

 

I have a requirement of creating a HR case in which the after selecting subject person it should show whether use having HR profile or not.

 

Can anyone help me with the script.

1 ACCEPTED SOLUTION

Samaksh Wani
Giga Sage
Giga Sage

Hello @shadoworg 

 

Second Solution is that You can add reference Qualifier for that field.

 

Right Click on the Field> Configure Dictionary > Go to Related Tabs > Reference Specification > Choose Advanced.

 

Write the Calling of script include :-

javascript: new checkHRProfile().checkHRProfile();

 

Script Include code should be like :-

 

var gr = new GlideRecord('sn_hr_core_hr_profile');
gr.query();
while(gr.next()){
return gr.sys_id;
}

 

Plz mark my solution as Accept, If you find it helpful.

 

Regards,

Samaksh

View solution in original post

3 REPLIES 3

Samaksh Wani
Giga Sage
Giga Sage

Hello @shadoworg 

 

You need to write a onChange Client Script for that :-

 

var gr = new GlideRecord('sn_hr_core_hr_profile');
var sysId = g_form.getValue('subject_person');
gr.get(sysId);
if(!gr.next()){
alert('your msg');
return false;
}

 

Plz mark my solution as Accept, If you find it helpful.

 

Regards,

Samaksh

RaghavSh
Kilo Patron

1. Write an on change client script on subject person.

2. You cannot glide a table directly in client script so you will have to use glide ajax to check if the HR profile exists.

3. If it does not exist you can return false from your script include and pop up an alert accordingly.

 

Refer :https://developer.servicenow.com/dev.do#!/reference/api/utah/client/c_GlideAjaxAPI  for glideajax examples.


Please mark the answer correct/helpful accordingly.


Raghav
MVP 2023

Samaksh Wani
Giga Sage
Giga Sage

Hello @shadoworg 

 

Second Solution is that You can add reference Qualifier for that field.

 

Right Click on the Field> Configure Dictionary > Go to Related Tabs > Reference Specification > Choose Advanced.

 

Write the Calling of script include :-

javascript: new checkHRProfile().checkHRProfile();

 

Script Include code should be like :-

 

var gr = new GlideRecord('sn_hr_core_hr_profile');
gr.query();
while(gr.next()){
return gr.sys_id;
}

 

Plz mark my solution as Accept, If you find it helpful.

 

Regards,

Samaksh