User criteria is not working as expected
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2023 08:58 PM
Hi Community,
I've written below User Criteria for checking if the User is having 'HR Profile' and if satisfies then showing the Quick links in EC Portal. but even if the User is not having 'HR Profile' as true in sys_user table then the script is making the HR Profile as true in user table and HR Profile table. which shouldn't be the case. Any assistance where the script is going wrong? (when checked in logs for the user with HR Profile as false, is entering into 2nd if and coming Value as 1)
var userId = gs.getUserID();
var userRec = new GlideRecord('sys_user');
userRec.addQuery('sys_id',userId);
userRec.query();
if(userRec.next()){
var profile = userRec.getValue('u_has_hr_profile');
if(profile == true){
answer = true;
}
else{
answer = false;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2023 09:38 PM
Hi @Janu sree ,
I agree with anvesh here there must be some other BR or client script which might be running on user table. You can try searching for it by applying filter of script contains u_hr_has_profile.
If there is any script it will show u by this filter.
Thanks,
Danish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2023 09:07 PM
Hi @Janu sree
You can tr below script.
var userId = gs.getUserID();
var userRec = new GlideRecord('sys_user');
userRec.addQuery('sys_id', userId);
userRec.addQuery('u_has_hr_profile', true);
userRec.query();
if(userRec.next()){
answer = true;
} else{
answer = false;
}
Please mark my answer helpful and accept as solution if it helped you 👍✅
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2023 09:30 PM
Hi @AnveshKumar M -
Tried it. Again it is the same scenario happening. Even if the user is not having 'HR Profile' earlier, when Impersonating user, the script is making the Profile as true in table and entering into the if condition then showing the Quick link. Is there something which we can see why it is happening. Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2023 09:36 PM
Hi @Janu sree
I don't think this script is setting the value to true, it might be some other script. Please check Business Rules where the HR profile is being set to true on user record.
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2023 11:04 PM
@AnveshKumar M and @Danish Bhairag2 - And also after deactivating the business rule - whomever I'm impersonating it is throwing the below cross scope error.