I need to trigger survey on clicking of button in service portal widget
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2022 01:53 PM
I need to trigger survey from a portal widget, Let us know if anyone has worked on similar requirement.
Tried using below code, but receiving error.
new SNC.AssessmentCreation()).createAssessments('62d95a812f06011028f12f2ef699b611',"",usr)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-08-2022 03:28 AM
Hi Sirisha,
Can you provide more details on the error that you are receiving?
Regards,
Deepankar Mathur
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-08-2022 03:48 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-08-2022 03:32 AM
Hi Sirisha,
I hope you have created your survey and the state of the survey is "Ready to take".
Just follow this link to setup the survey widget:
https://docs.servicenow.com/bundle/rome-servicenow-platform/page/administer/survey-administration/concept/c_SurveyServicePortal.html
Mark my answer correct & Helpful, if Applicable.
Thanks,
Sandeep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-08-2022 03:36 AM
Also,
you can add code like this to your UI Action:
var typeSysID = ''; //The sys_id of the metric type or survey definition to generate assessments or surveys for.
var sourceRecordID = current.getValue('sys_id'); //One or more comma-separated sys_ids of records to include in the assessments generated. There must be an assessable record associated with the specified metric type for each source record. If this parameter is left blank, the assessments generated include all assessable records for the specified type. This parameter is for use with assessments only.
var userID = current.getValue('some_user_field'); //One or more comma-separated sys_ids of users to send assessment or survey instances to. If this parameter is left blank, the assessment stakeholders or survey users receive instances. This parameter is required for on-demand assessments.
new SNC.AssessmentCreation().createAssessments(typeSysID , sourceRecordID , userID );
There is another aaproach:
https://community.servicenow.com/community?id=community_question&sys_id=0d980b21db5cdbc01dcaf3231f9619d5