Trigger Survey Using Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2025 11:36 AM
I have a survey created. I want to to trigger it only when the hr case is closed by the user of the assignment group "Tier1"
So any of the user from the assignment group changes the state to close complete the survey named as "Survey for HR Case" will be triggering.
Is there any way of achieving this..if yes
Pls provide me the sample code.
Thankyou
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2025 11:58 PM
Hi @kumaar ,
You can add the trigger condition as below(Attached screenshot)
1. State changes to complete and Assignment group is "Tier1"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2025 12:02 AM
1) create after update business rule with your matching condition and check who closed the case
2) trigger the survey from script
See for details how the result looks like at:
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2025 12:59 AM
Hi @kumaar ,
You will have to create a BR.
It should be an After Update BR and the condition would be State Changes To Closed Complete.
Then in the advanced section you can use the below script:
var gr = new GlideRecord("sys_user_grmember");
gr.addEncodedQuery("group=8a5055c9c61122780043563ef53438e3^user="+current.closed_by);
gr.query();
if (gr.next()) {
var assessment = new SNC.AssessmentCreation();
//assessment.createAssessments(<sys_id of survey record>, <keep second parameter empty>, <to whom the survey will be assigned>)
assessment.createAssessments('502a2c44d7211100158ba6859e6103a3','',current.caller_id.toString());
}
If my answer has helped you in any way please mark it as correct or helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2025 05:27 AM
I dont see AssessmentCreattion Script include in my system...
Now how to proceed with it?