Where can i find the code for task number and short description on take_survey widget

Rocking Ravs
Giga Contributor

Where can i find the code for task number and short description on take_survey widget?

1 ACCEPTED SOLUTION

Dear Raveena,


I attempted to implement your requirement and below are the changes needed.


I made a screencast of how the changes look like, url to view the same (ServicePortalSurveyWidget - YouTube )



Test Data : Assignment Group = Service Desk


Caller Name = Abraham Lincoln


Caller Country = Spain ( ES)



** All changes to be made in scope = "Service Portal Surveys" **



Created copy of widget "Take Survey"   and named it as Take Survey 1


Created copy of page take_survey and named it as take_survey_1


Updated widget "My Surveys"



Changes done to the widget "Take Survey"   which are saved as the new widget Take Survey 1




In "Body HTML Template" add below code after


<div ng-if="data.trigger_desc" style="font-size:15px;">


{{::data.trigger_desc}}


</div>


<!-- custom Code Start -->


                                          <div ng-if="data.trigger_table == 'incident' && data.trigger_assignmentgroup != ''" style="font-size:15px;">


{{::data.trigger_assignmentgroup}}


</div>


                                            <div ng-if="data.trigger_table == 'incident' && data.trigger_caller != ''" style="font-size:15px;">


{{::data.trigger_caller}}


</div>


                                                <div ng-if="data.trigger_table == 'incident' && data.trigger_country != ''" style="font-size:15px;">


{{::data.trigger_country}}


</div>


                                          <!-- custom Code End -->


In "Server Script" add below code after sp.loadSurvey(typeId,surveyId, data);


// Custom Code


if(data.trigger_table == 'incident') {


var grInc = new GlideRecord('incident');


grInc.addQuery('sys_id', data.trigger_id);


grInc.query();


if(grInc.next()) {


data.trigger_assignmentgroup = grInc.assignment_group.name.toString();


data.trigger_caller = grInc.caller_id.name.toString();


data.trigger_country = grInc.caller_id.country.toString();


}


}


// Custom Code



Changes to page take_survey which are in the new page take_survey_1


Add the newly created widget in Row 1, Column 1


Changes to Widget "My Surveys"


Body HTML Template section 2 changes are done.


1. Comment out line <a href="?id=take_survey&instance_id={{::instance.sys_id}}" title = "Take {{::instance.evaluation_method_display}}"> and add new line


<a href="?id=take_survey_1&instance_id={{::instance.sys_id}}" title = "Take {{::instance.evaluation_method_display}}">



The updated code should look like below.



<!-- <a href="?id=take_survey&instance_id={{::instance.sys_id}}" title = "Take {{::instance.evaluation_method_display}}"> -->


<a href="?id=take_survey_1&instance_id={{::instance.sys_id}}" title = "Take {{::instance.evaluation_method_display}}">




2. Comment out line <a href="?id=take_survey&instance_id={{::instance.sys_id}}" title = "Take {{::instance.evaluation_method_display}}">


and add new line


<a href="?id=take_survey_1&instance_id={{::instance.sys_id}}" title = "Take {{::instance.evaluation_method_display}}">



The updated code should look like below.



<!-- <a href="?id=take_survey&instance_id={{::instance.sys_id}}" title = "Take {{::instance.evaluation_method_display}}"> -->


<a href="?id=take_survey_1&instance_id={{::instance.sys_id}}" title = "Take {{::instance.evaluation_method_display}}">


View solution in original post

8 REPLIES 8

Dear Raveena,


I attempted to implement your requirement and below are the changes needed.


I made a screencast of how the changes look like, url to view the same (ServicePortalSurveyWidget - YouTube )



Test Data : Assignment Group = Service Desk


Caller Name = Abraham Lincoln


Caller Country = Spain ( ES)



** All changes to be made in scope = "Service Portal Surveys" **



Created copy of widget "Take Survey"   and named it as Take Survey 1


Created copy of page take_survey and named it as take_survey_1


Updated widget "My Surveys"



Changes done to the widget "Take Survey"   which are saved as the new widget Take Survey 1




In "Body HTML Template" add below code after


<div ng-if="data.trigger_desc" style="font-size:15px;">


{{::data.trigger_desc}}


</div>


<!-- custom Code Start -->


                                          <div ng-if="data.trigger_table == 'incident' && data.trigger_assignmentgroup != ''" style="font-size:15px;">


{{::data.trigger_assignmentgroup}}


</div>


                                            <div ng-if="data.trigger_table == 'incident' && data.trigger_caller != ''" style="font-size:15px;">


{{::data.trigger_caller}}


</div>


                                                <div ng-if="data.trigger_table == 'incident' && data.trigger_country != ''" style="font-size:15px;">


{{::data.trigger_country}}


</div>


                                          <!-- custom Code End -->


In "Server Script" add below code after sp.loadSurvey(typeId,surveyId, data);


// Custom Code


if(data.trigger_table == 'incident') {


var grInc = new GlideRecord('incident');


grInc.addQuery('sys_id', data.trigger_id);


grInc.query();


if(grInc.next()) {


data.trigger_assignmentgroup = grInc.assignment_group.name.toString();


data.trigger_caller = grInc.caller_id.name.toString();


data.trigger_country = grInc.caller_id.country.toString();


}


}


// Custom Code



Changes to page take_survey which are in the new page take_survey_1


Add the newly created widget in Row 1, Column 1


Changes to Widget "My Surveys"


Body HTML Template section 2 changes are done.


1. Comment out line <a href="?id=take_survey&instance_id={{::instance.sys_id}}" title = "Take {{::instance.evaluation_method_display}}"> and add new line


<a href="?id=take_survey_1&instance_id={{::instance.sys_id}}" title = "Take {{::instance.evaluation_method_display}}">



The updated code should look like below.



<!-- <a href="?id=take_survey&instance_id={{::instance.sys_id}}" title = "Take {{::instance.evaluation_method_display}}"> -->


<a href="?id=take_survey_1&instance_id={{::instance.sys_id}}" title = "Take {{::instance.evaluation_method_display}}">




2. Comment out line <a href="?id=take_survey&instance_id={{::instance.sys_id}}" title = "Take {{::instance.evaluation_method_display}}">


and add new line


<a href="?id=take_survey_1&instance_id={{::instance.sys_id}}" title = "Take {{::instance.evaluation_method_display}}">



The updated code should look like below.



<!-- <a href="?id=take_survey&instance_id={{::instance.sys_id}}" title = "Take {{::instance.evaluation_method_display}}"> -->


<a href="?id=take_survey_1&instance_id={{::instance.sys_id}}" title = "Take {{::instance.evaluation_method_display}}">


I am looking for the similar solution. My survey is both Incident and Request. Can you please help.

Tyler Herman
Kilo Guru

Howdy,

No custom widgets are required for this. I've recently uncovered the answer to this issue and wanted to update this post and others to prevent folks from experiencing the pain I had.

The take_survey widget uses the "SPSurveyAPI" script include to get the trigger_desc. The "SPSurveyAPI" script include uses the blackbox script include "GlideSysTitle" to get the title of the trigger table for use as the trigger_desc. "GlideSysTitle" looks up the trigger table title from the sys_ui_title table. 

If your sys_ui_title table does not have an entry for the trigger table OR if it has an entry for the table but does NOT have a field populated to be used as the title, it will return the record number instead. Ensure that any table you are generating surveys on exists in sys_ui_title and has at least one field set, such as short description.

find_real_file.png

Thank you very much, you just saved the day for me!