- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-06-2023 07:39 PM
Hello everyone, I'm trying to show the Trigger Record number and short description on the top of a survey, for example if the survey was triggered by an Incident I would love to see the INC number and Short description at the top, my first thought was to check the service portal widget to see if there any option/setting to do this but unfortunately I couldn't find any, checking the widget [Survey and Assessments]
I did not see any fields or something on the HTML it appears that it renders the contents of the " assessment_take2 " UI page in portal, I decided to play with it and I was able to print some stuff, however when I try to bring the Record number and short description I got a undef message. see Image 1.
I tried using this code To get the TiggerID Record number usually it display like this (on my code I remove the : )
<g:evaluate var="jvar_task_number">
var gr = new GlideRecord("asmt_assessment_instance");
gr.get(instance);
var task_number= "";
itask_number = gr.getDisplayValue('trigger_id').split(': ')[1];
instance_number;
</g:evaluate>
<!-- few lines later near the main header I add this just near the <class="assessment"> div -->
<div>
<h1>${jvar_task_number}</h1>
</div>
And I get the following Error:
However if I hardcode the SysID on the jelly part I get the results I want:
Even I can pull the Short Description:
Unfortunatelly I lack of experience in Jelly I have no idea why using "instance" which is defined all over the code and used on other OOTB lines works but not on mine. here some example:
This block of code comes out of the box:
And when I print it I get results like:
Also this is only working on Default view not Portal and is required there but no clue, please help.
Please do not suggest these posts none of their code works these articles are pretty old. I already consumed time reading them.
https://www.servicenow.com/community/developer-forum/how-to-display-incident-number-and-short-descri...
https://www.servicenow.com/community/now-platform-forum/showing-trigger-id-record-on-survey/m-p/1062...
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2023 08:53 AM - edited ‎03-07-2023 08:55 AM
With the help of a colleague we found a way to make this work in portal view, customer want this only on Service Portal so I'll ignore the self-service view portion.
- Go to service portal and create a new empty widget
- On Server Script add the following:
(function() {
/* populate the 'data' object */
/* e.g., data.table = $sp.getValue('table'); */
var instanceId = $sp.getParameter('instance_id');
data.assessment = $sp.getAssessmentRecord(instanceId, '', data);
})();​
- On HTML template add the following:
<div class="panel panel-default">
<div class="panel-heading">Survey Details</div>
<div class="panel-body">
<div ng-if="data.assessment.trigger_id" style="font-size:15px;">
{{::data.assessment.evaluation_method_display}} ${is in reference to}
<a href="?id=ticket&table={{::data.assessment.trigger_table}}&sys_id={{::data.assessment.trigger_id}}">{{::data.assessment.trigger_display}}</a>
<div style="font-size:15px;">
{{::data.assessment.trigger_desc}}
</div>
</div>
</div>
</div>
- Save and publish your widget
- Go to Sevice Portal page editor and look for "take_assessment" page
- On "take_assessment" page drag and drop your custom widget on top of the "Survey and assessments" widget
- Assign yourself a valid survey ( The assessment instance must have a valid trigger ID other wise this won't work)
- **Important make sure to change your scope to Service Portal Survey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2023 08:53 AM - edited ‎03-07-2023 08:55 AM
With the help of a colleague we found a way to make this work in portal view, customer want this only on Service Portal so I'll ignore the self-service view portion.
- Go to service portal and create a new empty widget
- On Server Script add the following:
(function() {
/* populate the 'data' object */
/* e.g., data.table = $sp.getValue('table'); */
var instanceId = $sp.getParameter('instance_id');
data.assessment = $sp.getAssessmentRecord(instanceId, '', data);
})();​
- On HTML template add the following:
<div class="panel panel-default">
<div class="panel-heading">Survey Details</div>
<div class="panel-body">
<div ng-if="data.assessment.trigger_id" style="font-size:15px;">
{{::data.assessment.evaluation_method_display}} ${is in reference to}
<a href="?id=ticket&table={{::data.assessment.trigger_table}}&sys_id={{::data.assessment.trigger_id}}">{{::data.assessment.trigger_display}}</a>
<div style="font-size:15px;">
{{::data.assessment.trigger_desc}}
</div>
</div>
</div>
</div>
- Save and publish your widget
- Go to Sevice Portal page editor and look for "take_assessment" page
- On "take_assessment" page drag and drop your custom widget on top of the "Survey and assessments" widget
- Assign yourself a valid survey ( The assessment instance must have a valid trigger ID other wise this won't work)
- **Important make sure to change your scope to Service Portal Survey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-08-2025 03:10 AM
Its perfect solution.
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-01-2024 12:46 AM
Hi @GM5 ,
Do you have any information how the '$sp.getAssessmentRecord' function works?
We are trying to show survey result on the portal to other user than user passed a survey. We have investigated that $sp.getAssessmentRecord doesn't retrieve survey data for the user who didn't pass a survey. We still cannot find where the restriction is.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-15-2025 09:36 AM
Hi @Vadzim Surin1 ,
Did you ever figure this out? I'm also trying to show the assessment quiz score/result on the service portal when they take it. Thanks.