Survey task_record link

adrianps
Kilo Expert

I've put together a simple survey to get incident resolution feedback.  The survey is triggered when incident state is Resolved.

The Caller receives an email notification containing a link to the survey, which appears to work correctly.

When the Caller clicks on the link, it is taken to the SNow instance and is shown the following:

find_real_file.png

My question is with regards to the highlighted ${task_record} token above.  The underlying URL seems to be correct, but how do I get the variable replaced with a display value?

Cheers,

Adrian

7 REPLIES 7

adrianps
Kilo Expert

Hi harshtimes, I've taken a look at the link you provided, and it illustrates the modification to (a copy of) the incident_survey mail script that I implemented.

Specifically, declared a link variable that is populated by a call to AssessmentUtils().getAssessmentInstanceURL( current.sys_id ), followed by inserting this variable into the href tag.

What I'm trying to discover is the code that causes the temp message containing the ${task_record} variable (highlighted above).

I should mention that the URL referenced by ${task_record] is actually correct.  It's just the link display string that is not getting set.

adrianps
Kilo Expert

Minor update - it looks like the task_record link is configured in the UI Page: assessment_take2.

I'll keep digging to see what options are available...

adrianps
Kilo Expert

This is optimistic of me to declare, but I think I've found an error in the assessment_take2 UI Page HTML code.

The statements on lines 361-362 appear to be responsible for the text I highlighted above in my screenshot:

$[gs.getMessage('This {0} is in regards to {1}: ', msgArr)]
<a onClick="openTaskOverlay(event)" class="related-task-link">${gs.getMessage('${task_record}')}</a>

Given that when I click on the link, I do get an overlay of the correct task record, I have to assume that the error is simply with the code snippet that generates the display string:

${gs.getMessage('${task_record}')}

Looking at this snippet I believe the problems is that we are nesting two phase 1 JEXL statements - there is an outer statement and an inner statement.  The outer statement is:

${gs.getMessage('<innerJEXL>')}

...and the inner statement is:

${task_record}

I'm not even sure if it is possible to have nested JEXL statements that get processed in the same phase.  What I think is happening is that the outer statement is being interpreted, and is leaving behind the inner statement, explaining the link display string that I'm getting.

If you replace the outer curly brackets with square brackets, you get the desired behaviour.  i.e. update line 362 and 375 to read as follows:

<a onClick="openTaskOverlay(event)" class="related-task-link">$[gs.getMessage('${task_record}')]</a>

This causes the task_record variable to be replaced in phase 1, and the gs.getMessage function to be executed in phase 2.

 

Having said all that, I'm happy to be proven wrong.