Trigger assessment/survey to a group of users dynamically.

ShyamaA
Tera Contributor

I have a requirement to trigger an assessment/survey to a dynamic group depending on the CI and allow anyone in the group to take the assessment.

 

However, in the Trigger Condition table the User filed is a mandatory field and there are no options to select a group.

Can this be achieved through scripting?

 

2 REPLIES 2

sarah54casiano
Tera Contributor

Yes, it is possible to achieve this through scripting. You can create a script that dynamically fetches the group members and triggers the assessment/survey for each user in the group. This can be done by using a combination of PowerShell and API calls.

Here’s a high-level overview of the steps involved:
1. **Fetch Group Members:** Use a script to fetch the members of the group based on the CI (Configuration Item).
2. **Trigger Assessment/Survey:** Iterate through each member of the group and trigger the assessment/survey for each user.
3. **Handle Responses:** Optionally, handle and store the responses of the assessment/survey.

Here's an example script to give you an idea:

```powershell
# Step 1: Fetch Group Members
$groupName = "YourGroupName"
$groupMembers = Get-ADGroupMember -Identity $groupName | Select-Object -ExpandProperty SamAccountName

# Step 2: Trigger Assessment/Survey
foreach ($member in $groupMembers) {
# Replace with actual API call to trigger the assessment/survey
# For example, using Invoke-RestMethod to call the assessment API
$apiUrl = "https://your-assessment-api/trigger"
$body = @{
"user" = $member
"assessmentId" = "YourAssessmentId"
}
Invoke-RestMethod -Uri $apiUrl -Method Post -Body ($body | ConvertTo-Json) -ContentType "application/json"
}

# Step 3: Optionally Handle Responses
# Add logic to handle and store responses if needed
```

This is just a basic example to get you started. You'll need to replace the placeholder values (e.g., group name, API URL, etc.) with your actual floridablue values and add any additional logic specific to your requirements.

 

ShyamaA
Tera Contributor

Thank you for your response, Sarah.

We don't need to fetch the groups from AD. They are already created in ServiceNow.

The scenario is:

We want to trigger a survey from a CI based on some trigger conditions.

But, before triggering the survey, we want to query the cmdb_rel_team table by the current CI and the "group type" field as "XYZ" and fetch the group from the "user group".

Then, trigger the survey to the users in "User group"

 

However, the trigger condition table only has a user field and does not have a group field to trigger assessments to groups.

ShyamaA_0-1739161356138.png