- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-25-2019 08:48 AM
I would like to create Test Cases for completing a Normal Change Request. In our configuration users are required to fill out a Risk Assessment. When they click on the Risk Assessment button a modal window pops up and is displayed. They click on the radio box fields to complete the form and click Submit to compete the form. Once this is done, they can submit the Change Request for CAB review and approval.
How do I complete the Risk Assessment using ATF?
The solution provided in this article, doesn't work: https://community.servicenow.com/community?id=community_article&sys_id=f263108ddbd86b08a39a0b55ca961...
In our instance we don't have a survey_instance table.
I have tried using ATF to insert the records and using Click Modal Button.
For the ATF insert record I did the following:
1. Record insert: Assessable Record
2. Record insert: Assessment Instance
3. Record insert: Assessment Instance Question ( x 8, one for each of the 8 questions we have)
4. Record insert: Metric Result (x 8, one for each of the 8 questions answered)
5. Record Update: Assessment Instance - set state to complete
Is there something I am missing?
For the Click Modal Button, I open the popup form and then use the Click Modal Button step, but I can't select the window.
The window options related to risk assessment I see are:
1. change_risk_asmt_close_dialog
2. change_risk_asmt_dirty_form_dialog
3. change_risk_completed_asmt_dialog
I would like to use the Click Modal Button, as it would mimic the user. Has anyone done this?
Solved! Go to Solution.
- Labels:
-
Change Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-03-2021 07:23 AM
Hi Rini,
I did get this working and have been using it for a while now. I created a Step Configuration. It has one little problem, once the risk assessment has been created, the risk assessment needs to be opened and saved again. We have our own version of the Risk Assessment.
Here is an example of it in use:
Here is the script I use in the Step Execution Script:
(function executeStep(inputs, outputs, stepResult, timeout) {
var outMessage = "";
// logMessage(" Complete Risk Assessment -- START!!!!!!!!!!!!!!");
var changeID = inputs.u_change_request;
var metricType = getMetricType();
// insert record into assessment_instance
var gr_asm_int = new GlideRecord('asmt_assessment_instance');
gr_asm_int.initialize();
gr_asm_int.metric_type = metricType;
gr_asm_int.state = 'wip';
gr_asm_int.task_id = changeID;
gr_asm_int.insert();
var asm_Metric_Cat = getMetricCategory();
// fill out the questions
var returnResult = insertAsmQuestion(gr_asm_int.sys_id, asm_Metric_Cat, changeID, "Users Impacted By Implementation", inputs.u_users_impacted_by_implementation.getDisplayValue());
if (returnResult) {
returnResult = insertAsmQuestion(gr_asm_int.sys_id, asm_Metric_Cat, changeID, "Resources Required to Implement Change", inputs.u_resources_required_to_implement_change.getDisplayValue());
}
if (returnResult) {
returnResult = insertAsmQuestion(gr_asm_int.sys_id, asm_Metric_Cat, changeID, "Implementation Duration", inputs.u_implementation_duration.getDisplayValue());
}
if (returnResult) {
returnResult = insertAsmQuestion(gr_asm_int.sys_id, asm_Metric_Cat, changeID, "Exposure", inputs.u_exposure.getDisplayValue());
}
if (returnResult) {
returnResult = insertAsmQuestion(gr_asm_int.sys_id, asm_Metric_Cat, changeID, "Business Cycle Timing", inputs.u_business_cycle_timing.getDisplayValue());
}
if (returnResult) {
returnResult = insertAsmQuestion(gr_asm_int.sys_id, asm_Metric_Cat, changeID, "Scheduling/Outage Requirements", inputs.u_scheduling_outage_requirements.getDisplayValue());
}
if (returnResult) {
returnResult = insertAsmQuestion(gr_asm_int.sys_id, asm_Metric_Cat, changeID, "Technical Capability", inputs.u_technical_capability.getDisplayValue());
}
if (returnResult) {
returnResult = insertAsmQuestion(gr_asm_int.sys_id, asm_Metric_Cat, changeID, "Privacy", inputs.u_does_this_change_expose_personal_data.getDisplayValue());
}
if (returnResult) {
// complete the risk assessment
var gr_asm_int_upd = new GlideRecord('asmt_assessment_instance');
gr_asm_int_upd.get('sys_id', gr_asm_int.sys_id);
gr_asm_int_upd.state = 'complete';
gr_asm_int_upd.update();
outMessage = gs.getMessage('Risk Assessment has been created. \n');
outMessage += gs.getMessage('Users Impacted By Implementation: ' + inputs.u_users_impacted_by_implementation.getDisplayValue() + '\n');
outMessage += gs.getMessage('Resources Required to Implement Change: ' + inputs.u_resources_required_to_implement_change.getDisplayValue() + '\n');
outMessage += gs.getMessage('Implementation Duration: ' + inputs.u_implementation_duration.getDisplayValue() + '\n');
outMessage += gs.getMessage('Exposure: ' + inputs.u_exposure.getDisplayValue() + '\n');
outMessage += gs.getMessage('Business Cycle Timing: ' + inputs.u_business_cycle_timing.getDisplayValue() + '\n');
outMessage += gs.getMessage('Scheduling/Outage Requirements: ' + inputs.u_scheduling_outage_requirements.getDisplayValue() + '\n');
outMessage += gs.getMessage('Technical Capability: ' + inputs.u_technical_capability.getDisplayValue() + '\n');
outMessage += gs.getMessage('Privacy: ' + inputs.u_does_this_change_expose_personal_data.getDisplayValue() + '\n');
stepResult.setOutputMessage(outMessage);
stepResult.setSuccess();
return true;
} else {
outMessage = gs.getMessage('Unable to create Risk Assessment');
stepResult.setOutputMessage(outMessage);
stepResult.setFailed();
return false;
}
}(inputs, outputs, stepResult, timeout));
function insertAsmQuestion(asmID, asmCat, chgID, asmMetric, questAnswer) {
returnResult = false;
// get the metric question
var gr_asm_metric = new GlideRecord('asmt_metric');
gr_asm_metric.addQuery('name', asmMetric);
gr_asm_metric.addActiveQuery();
gr_asm_metric.query();
if (!gr_asm_metric.next()) {
return false;
}
// get the answer
var gr_metric_def = new GlideRecord('asmt_metric_definition');
gr_metric_def.addQuery('sys_name', questAnswer);
gr_metric_def.addQuery('metric', gr_asm_metric.sys_id);
gr_metric_def.query();
if (!gr_metric_def.next()) {
return false;
}
// insert the question response
var gr_asm_question = new GlideRecord('asmt_assessment_instance_question');
gr_asm_question.initialize();
gr_asm_question.instance = asmID;
gr_asm_question.category = asmCat;
gr_asm_question.source_table = "change_request";
gr_asm_question.metric = asmMetric;
gr_asm_question.source_id = chgID;
gr_asm_question.metric = gr_asm_metric.sys_id;
gr_asm_question.value = gr_metric_def.value;
gr_asm_question.insert();
returnResult = true;
return returnResult;
}
function getMetricType() {
// get metric type - BCA Change Risk Assessment
var gr_metric_type = GlideRecord('asmt_metric_type');
var returnValue = gr_metric_type.get('sys_name', 'BCA Change Risk Assessment');
// logMessage("found metric type:" + gr_metric_type.sys_id);
if (returnValue) {
return gr_metric_type.sys_id;
} else {
return;
}
}
function getMetricCategory() {
var gr_metric_category = GlideRecord('asmt_metric_category');
var returnValue = gr_metric_category.get('sys_name', 'BCA Change Risk Assessment Category');
if (returnValue) {
return gr_metric_category.sys_id;
} else {
return;
}
}
function logMessage(message) {
gs.sleep(1000);
gs.info("RWS-ATF - " + message);
}
In case you want it, I have attached the Set Configuration that I created as an update set.
Cheers,
Rob.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-25-2019 11:10 AM
I don't believe you will be able to fill out the risk assessment on the form directly with ATF. After you submit the change form, you can open a new risk assessment like as a new record on its table, fill out that as a form separately and you can select the change request you want to associate that risk assessment to by selecting the output from the previous step (where you submitted the change form so the sys_id is passed on to the next step).
And then continue with submitting the change request.
The same procedure applies to work with change tasks as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-25-2019 12:00 PM
Nitesh,
That sounds like a solution. What form should be opened? I tried 'asmt_assessment_instance' as I thought that would be the start, but that didn't work. I can only update the 'assigned to', the other fields are read only.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-25-2019 11:18 AM
ATF Steps for Change Risk Assessment [HOWTO]
Please follow this link as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-25-2019 11:48 AM
Nitesh,
I referenced that link and it talks about survey_instance table, we don't have that. So this doesn't work.