Configure My Assessment Cards & Surveys .do page

toneyvecchio1
Tera Expert

Hi Team!

We are firing up Demand and looking into modifying the page for My Assessments & Surveys: assessment_list.do

I am unable to find that URL anywhere in my CMS. Though I am not very CMS familiar I pretty much searched everywhere I could find and am at a loss. Could anyone explain how I might modify this page?

Ultimately my goal is on the nice display page is to use the Demand Name instead of "Demand" in both locations so that stakeholders.. you know.. know what Assessment they are about to take. I think I should be able to figure it once I can find it any help of course is appreciated!

SN Dev - Surveys.png

11 REPLIES 11

Well, got a little further but haven't cracked it. For anyone who might be trying:



Back at UI Page > assessment_list, the HTML section builds an array called data, with code of note shown below:


arr[6] = gr.due_date.toString();


arr[7] = mt.description.toString();


arr[8] = mt.evaluation_method.getDisplayValueExt().toString();



So this is where you build the value of what we want to display on the survey cards. It actually gets utilized in building the card down at the Client Script area line 86.


body += '<span style="color:#000; white-space:normal;">' + getMessage("State") + ': </span><span style="color:#888; white-space:normal;">' + data[id+5] + '</span><br>';


Here, or in the code around it, you can hijack what the Survey Card displays. For this example I'm using the "State" field on the survey card. I'm no programmer so I am scratching my way there, but I think if you set in the array from HTML to have the short description, then you can get it to display in the card where you see data[id+x] you can get this to work.



Using array id 6 (aka data[id+6] in client script) makes Due Date on the survey card correctly show up now, that's the out of box. I found some other array IDs work fine, but I figured using arr[7]=mt.short_description.toString(); in HTML then using data [id+7] in the Client Script word work but it didn't. Still missing something, but its closer. Anyone know if I am way of course though?


If you check the code where it builds the array, it declare two variables:



        var gr = new GlideRecord("asmt_assessment_instance");


        var mt = new GlideRecord("asmt_metric_type");



I have checked out both of these tables and neither store the name of the Demand or have a link to the dmn_Demand table where the title of the Demand is initially stored.   Eventually the name of the Demand is saved as a Task and can be found in thge Task table - but again i am not sure of the key that will allow me to access it.



When you launch the actual Assessment at the top of the tree it has the name of the Demand, but I think I have found the UI script that builds the Assessment form (assessment_take2) but I am unable to determine how/where it retirives the name of the Demand.


Assessment.png
If you attempt to submit an uncompleted assessment then you get this error



Error.png



and I have been able to trace it back to the 'assessment_take2 - client script.



Function.png



I can trace 'assessbaleLabel' back to



assessibleLabel.png


But this where the trail goes cold!


jakob_richardso
Kilo Contributor

Hi Toney,



I don't have demand installed, but I did just have to make a similar customization for our Survey needs.



On the assessment_list UI page, in the HTML field, after the following line:


                      arr[2] = mt.name.toString();


I added the code:


                      if(gr.trigger_id) arr[2] += ": " + gr.trigger_id.getDisplayValue();


The result is that the number of the generating Task record is appended to the survey name.


12-3-2014 3-59-43 PM.png


This may be applicable to your use case if there is a reference to the Demand record in any of the Document ID fields on the Instance glide record (trigger_id, related_id_1 - 4). Let me know if you have any questions - thanks for helping me find which page to edit .


toneyvecchio1
Tera Expert

Jakob pretty much cracked it for Incident Survey, which I was looking to do for that as well.



I wanted to take a step further and have the display name of Incident take a whole line alone so I tried adding a new array entry that wasn't being used yet. Attempts worked great for incident but totally crashed the Demand Assessment card... Figured I would post my findings and maybe someone might be able to take it to the next level.



My attempt


Navigate to UI Page > Assessment List



In the HTML you need to set a value, around line 45-50 or so it builds the array. I added a new line for arr[12] as 11 was being used just a few lines down, and made it the short description of the trigger record (The source incident in the case of the Incident Survey)



find_real_file.png



Now we need to call it, in the client script around line 82 in mine, it calls id+2 which gets the survey name. Instead of modifying what arr[2] was, I change it to call my new arr[12]


find_real_file.png





This ended up changing my Survey Card to display the incident name which was awesome.. however Demand Survey cards no longer generated at all. Jakobs solution didn't break the cards, however I am still looking for the ideal setup below.


find_real_file.png


I am working on trying to do the same thing, and I think I am pretty close.   In the XML portion, I inserted the following code, which allows me to grab the demand record and other task based records as well.


}



                while (gr.next()) {



  var question = new GlideRecord('asmt_assessment_instance_question');


  question.addQuery('instance',gr.sys_id);


  question.query();


        var ans1 = '';


        var ans2 = '';


        var ans3 = '';


  if (question.hasNext()) {


  question.next();


  if (question.source_table == 'asmt_metric_type') {


  ans1 = gr.trigger_id.toString();


                  ans2 = gr.trigger_table.toString();


                  ans3 = gr.trigger_id.getDisplayValue() + ' - ' + gr.trigger_id.short_description;


  } else {


  ans1 = question.source_id.toString();


                  ans2 = question.source_table.toString();


                  ans3 = question.source_id.number.toString() + ' - ' + question.source_id.getDisplayValue().toString();


  }


  }


I then add the answer values to the array that is used in the client script..


                arr[13] = ans1;


                arr[14] = ans2;


                arr[15] = ans3;


Then, in the buildCards function of the client script, you need to change the line that says j = i * 12 to match how many variables you have.   Finally, under the buildBody function, I added the following lines of code


if (data[id+14] != '') {



  body += '<span>';


  body += '<h2 style="margin: 10px 0px 0px 0px; font-size:larger; font-weight:normal;">';


  body += '<a target="_blank" style="color:#000;" href="nav_to.do?uri=' + data[id+14] + '.do?sys_id=' + data[id+13] + '">' + data[id+15] + '</a>';


  body += '</span><br>';


  }