How to show survey questions or categories based on assigned user's group or custom field?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-02-2025 11:49 AM
Hi everyone,
I'm working with ServiceNow Surveys and I'd like to know if there's a way to conditionally display survey questions or entire categories based on attributes of the assigned user.
For example, I want to show certain questions only if the user belongs to a specific group or if a custom boolean field on the user record (like u_cliente_ganado) is true.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-02-2025 11:54 AM
Hi @JuanCarlosV I found these steps :
You can achieve this by using the "Condition" field on each question or category within the survey designer. This field allows you to specify conditions using ServiceNow's "GlideForm" syntax, effectively filtering which users see which questions or categories.
Here's how you can implement it:
1. Access Survey Designer:
Navigate to Survey > View Surveys and select the survey you want to modify.
2. Locate the Question or Category:
Open the specific question or category you want to conditionally display.
3. Set the Condition:
In the "Condition" field, use GlideForm syntax to define the criteria based on user attributes. For example, to show a question only to users in the "IT" department, you might use: gs.getUser().getDepartment() == 'IT'.
4. Multiple Conditions:
You can combine conditions using AND/OR logic to create more complex scenarios.
5. Apply to Categories:
The same "Condition" field is available for survey categories, allowing you to conditionally display entire sections of the survey.
6. Testing:
After setting the conditions, test the survey with different users to ensure the logic is working as expected.
Example:
Let's say you have a survey with two categories: "General Feedback" and "Technical Issues". You want to show the "Technical Issues" category only to users with the "itil" role. You would:
Open the "Technical Issues" category.
Set the "Condition" field to: gs.hasRole('itil').
This will ensure that only users with the "itil" role will see the "Technical Issues" category.
Mark my answer helpful if it works for you 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-02-2025 03:41 PM
It asks me to select a table, do I have to select the user's table (sys_user)?