Surveys - How to show different end notes depending on survey answers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-25-2018 03:10 AM
I would like to create a survey where if they answer yes to a specific set of questions, it would create a record in a table, and show a link to that table, otherwise, it shows generic text.
Could anyone tell me on how to do this please?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-25-2018 01:56 PM
Hi F - Can you help me better understand your intent? Why would a user be redirected to a table? What are you wanting to present to them?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-29-2018 02:23 AM
So, the survey is sort of like a pre-screening questionaire. It should create a record in a table if a combination of answers are chosen, and if they are, they should be notifed that the record has been created and it should display a hyperlink to that record. Otherwise, they would just be given generic information that they dont need to do anything further.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-29-2018 05:04 AM
Hi,
Go to UI Page - "assessment_thanks"
Modify the HTML field, use the below script,
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:evaluate var="jvar_assessment_type" jelly="true">
var evaluation_type = jelly.sysparm_assessment_type?jelly.sysparm_assessment_type:gs.getMessage('assessment');
gs.addInfoMessage(gs.getMessage('You have completed this {0}', evaluation_type));
evaluation_type;
</g:evaluate>
<div data-form-title="$[gs.getMessage('You have completed this {0}', '${jvar_assessment_type}')]">
<g2:evaluate var="jvar_item" jelly="true" expression="
gr = new GlideRecord('asmt_metric_type');
gr.addQuery('sys_id', jelly.sysparm_assessable_type);
gr.query();
" />
<g2:evaluate var="jvar_item1" jelly="true" expression="
var test = 'jelly.sysparm_assessable_type';
var gr1 = new GlideRecord('asmt_assessment_instance');
gr1.addEncodedQuery('metric_type='+jelly.sysparm_assessable_type+'^state=complete');
gr1.orderByDesc('number');
gr1.query();
if(gr1.next()){
var ast_inst_link = 'asmt_assessment_instance.do?sys_id='+gr1.sys_id;
}
ast_inst_link;
"/>
<j2:if test="$[gr.next()]">
<!-- end_note may contain HTML formatting -->
<g2:no_escape>$[NS:gr.end_note]</g2:no_escape>
</j2:if>
<label>Assessment Instance: <a href='$[jvar_item1]' target='_blank'>$[gr1.number]</a></label>
</div>
</j:jelly>
I have added a link that will point to the assessment instance created.
Please mark the answer as correct/helpful
Regards,
Suraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-30-2018 02:56 AM
Thanks, this is steering me in the right direction. However, I am working on a scoped application, and would not like to mess with anything global. Any workarounds? I tried a business rule on the survey, which contains a redirect to a UI page, but that isn't reliable, as if you switch to another tab that's on the servicenow platform, it won't redirect the page I was on.