How to implement Impact assessment for a change similar to Risks?

rathikaramamurt
Giga Expert

Hi Experts,

I need to implement Impact assessment with set of questions/scores same like it is existing for Risk Assessment in the change form.

I have a list of questions and scores provided separately for both Risk as well as Impact, and can see that currently Risk assessment is already implemented, which also calculates Impact with it for each change by default.

I need to perform this action separately for both Risk & Impact. I have gone through few links Using Change Risk Assessment - ServiceNow Wiki which explains the concept clearly, for this.

However, there are links(UI actions) mentioned in this page like "Fill out Risk Assessment" and "Execute Risk Calculation". The 1st UI action, contains set of question only for Risks which calculates based on scores. Similarly I need to implement this for Impact as well like adding new UI actions only for Impact something like this--> "Fill out Impact Assessment" and "Execute Impact Calculation". I know I can copy paste same code for Impact as well, but need to know some additional background scripts running behind this, i.e., BRs and Script includes, also System properties. How these are inter related.

Could any one please guide me on this?

1 ACCEPTED SOLUTION

rathikaramamurt
Giga Expert

Hi,



I have implemented this for Impact assessment by creating a table for Impact Assessment similar as Risk Assessment. Also, applied same scripts for Impact process separately as similar to Risks.



Hence, Marking this as resolved.


View solution in original post

12 REPLIES 12

And 2 Script includes as below:


1. CreateImpactAssessment


script:


var CreateImpactAssessment = Class.create();




CreateImpactAssessment.prototype = Object.extendsObject(AbstractAjaxProcessor,{


//   initialize : function() {


//   },




  checkImpactAssessment: function() {


    var id = this.getParameter('sysparm_id');


    var tabClass = this.getParameter('sysparm_class');


    var assessmentID = '';


    var match = false;




    //fetch the change record


    var gr2 = new GlideRecord(tabClass);


    gr2.get(id);




    //see if an assessment already exists for this current change


    var tai = new GlideRecord('task_assessment');


    tai.addQuery('task', gr2.sys_id);


    tai.query();




    //look for matching assessment to attach //attaches the assessment to this current change based on matching assessment conditions


    var aci = new GlideRecord('assessment_conditions');


    aci.addQuery('table', tabClass);


    aci.addActiveQuery();


    aci.orderBy('order');


    aci.query();


    var retTAImpact = 'No Condition';


    while (aci.next()) {


          var filter = GlideFilter;


          match = filter.checkRecord(gr2, aci.condition);  


    //if condition matches, sets related task assessment to this current change


          if (match){


              retTAImpact = this._setAssessment(gr2, aci, tai);


              break; //match found so use this one


          }


    }


    //if condition not matches, deletes related task assessment


    if (retTAImpact == 'No Condition' && tai.next()){


        tai.deleteRecord();


    }


    return retTAImpact;


  },



  /**


  * Prevent public access to this processor


  */


  isPublic: function() {


  return false;


  },




//look for existing assessment against the task - there should be only one!


//If a task_assessment exists and the assessment to take has changed then delete the existing and create a new one


//if no task_assessment exists then create a new one


  _setAssessment: function(task, aci, tai) {


      var reti = '';


      if (tai.next()){


          // Existing assessment instance exists and is of the same type


          if (tai.assessment == aci.assessment){


              reti = tai.sys_id + ',' + tai.assessment.name;


          }


          // Existing assessment instance exists and is different so delete and associate correct one


          else{


              tai.deleteRecord();


              reti = this._create_task_assessment(tai, task.sys_id, aci);


          }


      }


      // First time assessment taken so create new one


      else{


          reti = this._create_task_assessment(tai, task.sys_id, aci);


      }


      return reti;


  },



  _create_task_assessment: function(gr2, taskID, assessment) {


          gr2.initialize();


          gr2.task = taskID;


          gr2.assessment = assessment.assessment;


          gr2.insert();


          var impName = assessment.assessment.name;


          var impId = gr2.sys_id;


          var impact = impId + ',' + impName;


          return impact;


  },


type: 'CreateAssessment'


});



2.         IACalculator


var IACalculator = Class.create();


IACalculator.prototype = {


      initialize: function(_gr) {


              this._gr = !_gr ? current : _gr;


      },




calculateImpact: function(_current) {


              // Need to recall initialize if this script is invoked without a GlideRecord


              if (_current)


                      this.initialize(_current);


              var msg = '';


              //var cmsg = '';


              var color = '<FONT COLOR="red">';


              var colorEnd = '</FONT>';


              var finalImpact = '';


              var finalImpactLabel = '';




              // Set the impact based on the assessment if one has been taken.


              var taGR = new GlideRecord('task_assessment');


              taGR.addQuery('task', this._gr.sys_id);


              taGR.query();


              if (taGR.next()) {


                      var masterAssessment = taGR.assessment;


                      var instance = taGR.instance;




                      if (instance && masterAssessment) {


                              var compositeScore = this.calcCompositeScore(instance);


                              this.u_impact = this.getImpact(masterAssessment, compositeScore);




                              this._gr.u_impact_value = compositeScore;




                              if (!this.u_impact.impactVal)




                                      msg += gs.getMessage('No threshold could be found for the impact assessment');




                              else {


                                      finalImpact = this.u_impact.impactVal;


                                      finalImpactLabel = this.u_impact.label;


                                      msg += gs.getMessage('Impact assessment evaluated. Impact') + ' : ' + color + this.u_impact.label + colorEnd;


                              }


                      }




                      if (msg != '')


                              gs.addInfoMessage(msg);




              }




              // process risk conditions - impact will always run, risk will only be set if higher than risk based assessment risk.


              var calculate = new RiskCalculator(this._gr);


              var ri = calculate.calculateImpact();




              if (finalImpact != '' && finalImpact != null) {


                      this._gr.u_impact = finalImpact;




                      // if both assessment and conditions have been run then show overall impact to be set


                      if (msg != '')


                              gs.addInfoMessage(gs.getMessage('Impact for this change is set to') + ' : ' + color + finalImpactLabel + colorEnd);




              }


      },




      // adds all weighted scores to calculate the composite score


      calcCompositeScore: function(instance) {


              var score = 0;




              var srGR = new GlideRecord('survey_response');


              srGR.addQuery('instance', instance);


              srGR.addNotNullQuery('answer_integer');


              srGR.query();


              while (srGR.next())


                      score += srGR.answer_integer;


              return score;


      },




      // gets the impact based on the impact assessment threshold records


      getImpact: function(masterAssessment, compositeScore) {


              var match = false;


              var retImpact = new Object();




              var ratGR = new GlideRecord('u_impact_assessment_thresholds');


              ratGR.addActiveQuery();


              ratGR.addQuery('u_assessment', masterAssessment);


              ratGR.orderByDesc('u_score_greater_than');


              ratGR.query();


              while (ratGR.next() && !match) {


                      if (ratGR.u_score_greater_than < compositeScore) {


                              match = true;


                              retImpact.impactVal = ratGR.u_impact.toString();


                              retImpact.label = ratGR.u_impact.getDisplayValue();


//gs.addInfoMessage('impactVal : ' + retImpact.impactVal);


//gs.addInfoMessage('label : ' + retImpact.label);


                      }


              }




              return retImpact;


      },




      // returns first matching impact assessment


      checkForMatchingAssessment: function(tabClass, gr) {


              var match = false;


              var matchingRA = '';




              var ac = new GlideRecord('assessment_conditions');


              ac.addQuery('table', tabClass);


              ac.addActiveQuery();


              ac.orderBy('order');


              ac.query();


              while (ac.next()) {


                      var filter = GlideFilter;


                      match = filter.checkRecord(gr, ac.condition);


                      if (match) {


                              matchingRA = ac.assessment;


                              break;


                      }


              }




              return matchingRA;


      },




      // returns the impact assessment associated to the task id


      checkForAssessmentInstance: function(id) {


              var masterAssessment = '';




              var ta = new GlideRecord('task_assessment');


              ta.addQuery('task', id);


              ta.addNotNullQuery('instance');


              ta.query();


              if (ta.next())


                      masterAssessment = ta.assessment;




              return masterAssessment;


      },




      type: 'IACalculator'


};


Thanks Rathika,



I actually implemented it this noon using the ui actions and the script includes which are used for the change management module risk assessment.



Regards


Yogish


Hi @yogesh15dd , @rathikaramamurt , I have a requirement to create new pop up form "BCA exception questionnaire" which is same like Risk assessment , I tried to implement by using the ui actions and the script includes which are used for the change management module risk assessment , But it is not working for me while try to click on the link there is no pop up form appeared. could you please guide me on that.

Thank you.