Show task information within Survey page

scottcornthwait
Kilo Expert

Hello Everyone,

I'm looking to find out if anyone has been successful at adding in any form of information from a task record which gets sent out by a survey trigger. Specifically what i'm trying to do, is put a bit of information into the survey page from the task (things like short description, description, created date,   assigned to, and close date).

To my understanding, the only way to do this currently is to include that information within the survey invitation email as text. I would however love to put that information either above or below the survey questions when the user opens the survey instance.

We'll be using the newer survey assessments, and our instance is on Fuji patch 6.

Any guidance would be appreciated.

Scott

1 ACCEPTED SOLUTION

coryseering
ServiceNow Employee
ServiceNow Employee

Hi Scott and Robert,



I haven't touched anything survey-related in a couple of years, so this is a shot int he dark.



When you actually take an assessment, what is the URL of the assessment page? Is it using the UI Page "assessment_take2"? If so, you could modify that UI Page to display the information you want.



If you want to pass additional parameters into this page when the user visit, presumable you could tack addition parameters onto the assessment URL in the notification that getn out, then access from Jelly like any other UI Page would.



This might be way off base, but if it is using a UI Page to display the survey instance to the user, then you should be able to modify it to do what you want.


View solution in original post

9 REPLIES 9

I had though about trying to inject some jelly coding into the introduction text, but so far, I've been un-successful.


Just for the giggles, did you attempt to treat the Intro text like any other HTML mail text field?   Putting in entries like... ${number}


coryseering
ServiceNow Employee
ServiceNow Employee

Hi Scott and Robert,



I haven't touched anything survey-related in a couple of years, so this is a shot int he dark.



When you actually take an assessment, what is the URL of the assessment page? Is it using the UI Page "assessment_take2"? If so, you could modify that UI Page to display the information you want.



If you want to pass additional parameters into this page when the user visit, presumable you could tack addition parameters onto the assessment URL in the notification that getn out, then access from Jelly like any other UI Page would.



This might be way off base, but if it is using a UI Page to display the survey instance to the user, then you should be able to modify it to do what you want.


Good call Cory, that'll do it. I'm a bit skeptical of modifying it, but that will definitely be the spot I need to work on if this becomes a hard requirement of my effort.



Thanks for your help guys.


brianiac
Giga Contributor

Using Cory's suggestion would make it easy to add dynamic header/footer type items to your surveys.



Building on that, this is just an idea for dynamic questions, a bit hacky and would require editing the UI Page to take the survey. But modifying the Published URL that is sent in the notification, appending (for example) the short description in the query string:



var url = "https://yourSNinstance.com/nav_to.do??uri=assessment_take2.do%3Fsysparm_assessable&short_desc=" + ${trigger_id.short_description};



Then have placeholder text in your survey questions where you want your variables to go:


Was your problem {{short_desc}} fixed in a timely matter?



Then on the   UI page to take the survey, add <html><head><script><body> tags to make use of calling an onLoad function in the body:


<?xml version="1.0" encoding="utf-8" ?>


<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">


<html>


<head>


<script>


      function replaceSurveyText() {


              // custom java here to parse the query string


              // find your text you want to replace on the survey (possibly a tricky part, maybe get all elements by tag name, and match the innerHTML?)


              // replace your text (something like: myElement.innerHTML = myElement.innerHTML.replace(/\{\{short_desc\}\}/, valueFromQueryString);)


      }


</script>


</head>


<body onload="replaceSurveyText()">


... rest of survey UI Page code


</body>


</html>



Adding in logic so it doesn't run on every survey, etc.