- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2020 12:38 AM
Hi Team,
I have few hr topics which i need to restrict those for only permanent employees.we have custom field created on user table as "Role type" which is a choice field of contract and permanent.when logged in user is permanent employee then only my topic should visible.
I have added script in condition of the topic to available only for hr portal.Now how to add my script to fetch the user table field and check if logged in user is permanent employee then show this topic
condition:
Solved! Go to Solution.
- Labels:
-
Virtual Agent
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2020 05:03 AM
Hi Mark,
Below code is working fine now.I did with GlideRecord.may be it didn't get published the topic properly.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2020 12:47 AM
Hi there,
You could add a GlideRecord query or getRecord on the current user to obtain that custom field. With that, just add an if condition to check the custom field.
Would that help?
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP
---
LinkedIn
Community article list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2020 12:50 AM
For example:
var role_type = gs.getUser().getRecord().getValue('u_role_type');
if(role_type == 'something') {
return true;
}
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP
---
LinkedIn
Community article list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2020 02:22 AM
Hi Mark ,
Thank you for the quick response,but it is not working for me.please find the below code for your reference.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2020 02:30 AM
Add some debugging to verify where your script stops. Add some debugging to see if the variables used, actually contain the expected values. For example debug: role_type.
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP
---
LinkedIn
Community article list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field