How to create a user criteria with advance script ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2023 04:49 AM
Hi All,
I want to create an user criteria if the user location is one of location1,location2,location3 and the company is not company1, I have tried with the below user criteria script, but Its not working,
answer = checkCondition(); function checkCondition(country) { var usr = new GlideRecord('sys_user'); usr.addQuery('sys_id',user_id); usr.addQuery('location.name', 'IN', 'location1,location2,location3'); usr.addQuery('company.name', '!=', 'company1'); usr.query(); return usr.hasNext(); }
Can anyone help me on this ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2023 07:31 AM
Hello,
I think there is no mistake in your code.
(As you know, user_id is recommend instead of "gs.getUserID()" in user criteria advanced scripts)
So, You should check other points. (maybe...company or location name?)
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2023 09:46 PM
Hi @t_sadahisa - The company & locations name are correct, still Its not working. Do we have any other aspects as Its not working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2023 04:06 PM
Do you use user criteria in service portal ?
Please check following points.
1. Do you set system properties?
2. Do not make similar settings same as Usercriteria at the same time (example: role, etc.).
I heard user criteria is not working in the situation from collegue.
I'll hope my comment help you.