How to hide expired surveys on Service Portal

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-17-2017 10:08 AM
We noticed that all surveys available to a user is shown on the service portal even those that are already expired. Is there a way to hide or disable the expired surveys shown on the surveys page on Service Portal?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-17-2017 11:12 AM
1) Navigate to: System Scheduler -> Schedule Jobs
2) Run the job Cancel Expired Assessments
3)This will remove all the expired survey
You can schedule this job in order to remove the expired assessment

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-17-2017 11:26 AM
That is one way to do this, but we are looking into just showing the surveys that is not yet expired on the Service Portal survey page, can't we just add some script to the instance of that survey widget to exclude those with expired status?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-17-2017 06:28 PM
The script which pulls the list of surveys to be shown in 'My Surveys' widget is in the getSurveys() method of SPSurveyAPI script include. The OOB script doesn't pull the expired surveys (which are in canceled state). Please check the state of those instances and check if any customization has been done to the method I mentioned. Following is the OOB and the expected script.
getSurveys: function(maxLimit, showAll, data) {
var gr = new GlideRecord('asmt_assessment_instance');
gr.addQuery("metric_type.active", true);
gr.addQuery("metric_type.publish_state", "published");
gr.addQuery("preview", false);
gr.addQuery('user', gs.getUserID());
var sub = gr.addQuery('state', 'ready');
sub.addOrCondition('state','wip');
var sub1 = sub.addOrCondition('state','complete');
sub1.addCondition("metric_type.allow_retake","true");
sub1.addCondition("due_date", '>=', new GlideDateTime().getDisplayValue());
gr.orderByDesc('state');
gr.orderBy('due_date');
gr.orderBy('sys_created_on');
gr.query();
data.totalRecords = gr.getRowCount();
data.instances = [];
if (showAll)
data.maxRecords = data.totalRecords;
data.recordsShownMsg = gs.getMessage('First {0} of {1} shown', [data.maxRecords, data.totalRecords]);
var count = 0;
while (gr.next() && count < data.maxRecords) {
var instance = this.getAssessmentInstance(gr);
if (instance.state == 'complete' && instance.allow_retake == 'false')
continue;
data.instances.push(instance);
count++;
}
},
Thanks
Antin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-19-2018 01:29 AM
This might help you
https://community.servicenow.com/community?id=community_question&sys_id=cdfedb35db621f809d612926ca9619a9