How do I create a UI Action that will start a Survey on top of the current ticket?

Wayne Richmond
Tera Guru

This is the requirement: A manager wants to do quality assurance on tickets throughout the month. I have suggested we create a survey that can be started via the ticket by clicking a form button. This will start the survey on top of the open record. When completed it records the scores for each question and preferably the ticket reference number and the assignee.

The functionality I'm looking for appears to already exist when I enable the 'Change Management - Risk Assessment' Plug-in. This creates a UI Action form link that when clicked starts a survey:

find_real_file.png

find_real_file.png

I've looked at the UI Action for this Form link and it's too complicated for me to customise to meet my needs:

Table: Change Request

Client: Checked

Onclick: invokeAssessment()

Condition: !current.isNewRecord()

Script:

function invokeAssessment() {

      g_form.hideAllFieldMsgs();

      var id = g_form.getUniqueValue();

      var ga = new GlideAjax("CreateAssessment");

      ga.addParam("sysparm_name", "checkAssessment");

      ga.addParam("sysparm_id", id);

      ga.addParam("sysparm_class", "change_request");

      ga.getXMLAnswer(function(res) {

              if (res == "No Condition")

                      g_form.addInfoMessage(getMessage("There are no risk assessments defined for this request"));

              else {

                      var resArr = [];

                      resArr = res.split(",", 2);

                      var taskAsmtID = resArr[0];

                      var assessmentName = resArr[1];

                      var url = "survey_take.do?sysparm_survey=" + encodeURIComponent(assessmentName);

                      url += "&sysparm_task_assessment=" + taskAsmtID;

                      url += "&sysparm_survey_update=false";

  url += "&sysparm_stack=no";

                      var d = new GlideOverlay({

                              title: getMessage("Risk Assessment"),

                              iframe: url,

                              width: "60%",

                              height: "80%",

                              onAfterLoad: function() {

                                      d.autoDimension();

                                      d.autoPosition();

                                      d._createIframeShim();

                                     

                                      var iframe = d.getIFrameElement();

                                      var post_button = iframe.contentWindow.document.getElementById("post_survey");

                                      if (post_button.addEventListener) {

                                              post_button.addEventListener("click", function(eventObj) {

                                                      if (eventObj.view.mandatoryResult) {

                                                              d.close();

                                                      }

                                              });

                                      } else {

                                              post_button.attachEvent("onclick", function(eventObj) {

                                                      if (iframe.contentWindow.mandatoryResult) {

                                                              d.close();

                                                      }

                                              });

                                      }

                              }

                      });

                      d.render();

              }

      });

}

Anyone know how I can achieve this?

4 REPLIES 4

Bharath40
Giga Guru

Hi Wayne,



As far as I understood is that you want that as a Form button or on top of form instead of form link. If so Navigate to UI action and check form button and remove form link.


I want to launch my own survey from a Form button


dwolf
Giga Expert

If QA is the objective, I recommend utilizing Coaching Loops.


rohitservicenow
Mega Guru

Hi Wayne, 

I have the similar requirement where the L2 teams want to pass the feedback to L1 team when the ticket arrive their queue without performing the mandatory check. to achieve this fubnctionality, I wanted to take the advantage of the assessments, however having difficulties showing the assessments on the form as a UI action. 

Could you please let me know if you had any luck achieving your requirement, if so please let me know how did you achieve it? 

 

Thank you in advance. 

Rohit