- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2020 07:45 AM
Hi, We have a requirement from L2 teams where they want to have the possibility to share the feedback with L1 teams when the tickets are passed to L2 without the proper checks.
To achieve above, I am thinking to make use of assessments, but have difficulty creating an launching the assessment instance from ui action. Want to launch assessment instance in an ui page/new window so the users don't need to navigate to another page. Following is the script, I am using. It is creating the assessment instance, but not launching.
Please advise if any errors/corrections.
IF you think of another solution, please share it.
_______________________________________________________________-
var location;
var typeSysID = 'd898867a2f0750103b9f57892799b668'; //The sys_id of an "Assessment Metric Type" record (asmt_metric_type)
var createAssessmentOutput = (new SNC.AssessmentCreation()).createAssessments(typeSysID, "", gs.getUserID());
var assessmentDetailsArray = createAssessmentOutput.split(',');
var assessmentInstanceSysId = assessmentDetailsArray[0];
if (assessmentDetailsArray.length >= 3) {
var grAsmtInstance = new GlideRecord('asmt_assessment_instance');
if (grAsmtInstance.get(assessmentInstanceSysId)) {
grAsmtInstance.trigger_table = current.getTableName();
grAsmtInstance.trigger_id = current.getValue('sys_id');
grAsmtInstance.update();
location = 'assessment_take2.do?sysparm_assessable_sysid=' + grAsmtInstance.sys_id.toString() + '&sysparm_assessable_type=' + grAsmtInstance.metric_type.toString();
}
} else {
throw 'Could not create new Survey: not found';
}
} else {
throw 'Could not create new Survey:' + createAssessmentOutput;
}
window.open(location, "Feedback", "width=600,height=500,toolbar=yes,scrollbars=yes");
_____________________________________________________________
Thank you.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2020 08:13 AM
You mixed client and server side code. Use a Script include to handle the server side code and set the UI Action to Client like so:
And fill Onclick
UI Action script:
function onClick() {
var ga = new GlideAjax('global.customSurveyUtil');
ga.addParam('sysparm_name', 'createSurvey');
ga.addParam('sysparm_tablename', g_form.getTableName());
ga.addParam('sysparm_sysid', g_form.getUniqueValue());
ga.getXML(ajaxResponse);
function ajaxResponse(serverResponse) {
var answer = serverResponse.responseXML.documentElement.getAttribute("answer");
//window.open(answer, "Feedback", "width=600,height=500,toolbar=yes,scrollbars=yes");
g_navigation.openPopup(answer);
}
}
If g_navigation is not to your liking try the window.open.
Then create a script include. Set to Client collable:
var customSurveyUtil = Class.create();
customSurveyUtil.prototype = Object.extendsObject(AbstractAjaxProcessor, {
createSurvey: function () {
var typeSysID = 'd898867a2f0750103b9f57892799b668'; //The sys_id of an "Assessment Metric Type" record (asmt_metric_type)
var createAssessmentOutput = (new SNC.AssessmentCreation()).createAssessments(typeSysID, "", gs.getUserID());
var assessmentDetailsArray = createAssessmentOutput.split(',');
var assessmentInstanceSysId = assessmentDetailsArray[0];
var grAsmtInstance = new GlideRecord('asmt_assessment_instance');
if (grAsmtInstance.get(assessmentInstanceSysId)) {
grAsmtInstance.trigger_table = this.getParameter('sysparm_tablename');
grAsmtInstance.trigger_id = this.getParameter('sysparm_sysid');
grAsmtInstance.update();
return 'assessment_take2.do?sysparm_assessable_sysid=' + grAsmtInstance.sys_id.toString() + '&sysparm_assessable_type=' + grAsmtInstance.metric_type.toString();
}
},
type: 'customSurveyUtil'
});
Let me know if this works
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2020 05:22 AM
Thank you Willen. I think I will write a BR to copy the answers to work notes.
Yes, your response really helped me out, so will mark it as correct.
Thank you again for the timely response.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2024 03:15 AM
I tried this script and it is working but it is generating assessment record for all the records that is present in the table and not for the Specific one from which it is triggered via UI Action.
Please suggest solution how to trigger for specific records from which the assessment is opening.
Thanks,
Nisha Kumari
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2025 02:43 AM
Edit the code as below and it will work:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2023 09:46 AM
Hi Willem,
I am using same ui Action and Script Include to create new custom assessment. Looks like it is creating assessment in backend but I am not able to make it open in pop up window. Do you any suggestion for that?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2022 04:48 AM
Hi Willem,
I tried replicating the similar solution in Change Module where i need a assessment before considering a change as an expedited change, but problem i am facing is
01. The assessment is not popping up in the same window.
02. The assessment in getting created for all the change records not for the Specific one from which we are triggering it via UI Action.
below are the code will you help me here:
Script Include: customSurveyUtil
var customSurveyUtil = Class.create();
customSurveyUtil.prototype = Object.extendsObject(AbstractAjaxProcessor, {
createSurvey: function() {
var typeSysID = 'b5e8e52f1b1811900210a7d6b04bcb84'; //The sys_id of an "Assessment Metric Type" record (asmt_metric_type)
var createAssessmentOutput = (new SNC.AssessmentCreation()).createAssessments(typeSysID, "", gs.getUserID());
var assessmentDetailsArray = createAssessmentOutput.split(',');
var assessmentInstanceSysId = assessmentDetailsArray[0];
var grAsmtInstance = new GlideRecord('asmt_assessment_instance');
if (grAsmtInstance.get(assessmentInstanceSysId)) {
grAsmtInstance.trigger_table = this.getParameter('sysparm_tablename');
grAsmtInstance.trigger_id = this.getParameter('sysparm_sysid');
grAsmtInstance.update();
return 'assessment_take2.do?sysparm_assessable_sysid=' + grAsmtInstance.sys_id.toString() + '&sysparm_assessable_type=' + grAsmtInstance.metric_type.toString() + '&sysparm_trigger_id =' + grAsmtInstance.trigger_id.sys_id.toString();
}
},
type: 'customSurveyUtil'
});
UI Action: Expedite
function onClick() {
var ga = new GlideAjax('global.customSurveyUtil');
ga.addParam('sysparm_name', 'createSurvey');
ga.addParam('sysparm_tablename', g_form.getTableName());
ga.addParam('sysparm_sysid', g_form.getUniqueValue());
ga.getXML(ajaxResponse);
function ajaxResponse(serverResponse) {
var answer = serverResponse.responseXML.documentElement.getAttribute("answer");
g_navigation.openPopup(answer);
}
}