The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Surveys - How to show different end notes depending on survey answers

F_8
Tera Contributor

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?

4 REPLIES 4

Stephen Sturde
Tera Guru

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?

-Stephen

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.

surajp
Mega Guru

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

 

F_8
Tera Contributor

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.