How Do I Pass Risk Assessment Variables to Change Form?

rhett1
Tera Expert

Is there a way to pass risk assessment answers (Task Assessment) to specific Change form fields?

1 ACCEPTED SOLUTION

fschuster
ServiceNow Employee
ServiceNow Employee

Hi Rhett,



Absolutely, but first of all I would ask: why? The answers are nicely displayed in the "Risk Assessment" related list on the CHG record already. Why would you duplicate those? It's pretty much one-click away.



However, if you would really have to do that you could do the following:


  • On the Task Assessment record you have two references:
    • One to the actual CHG record ("Task")
    • One to the Survey Instance ("Instance")
  • The table Survey Response [survey_response] holds all the answers to a specific Survey Instance (which is the same reference as on the Task Assessment)
  • Create a business rule on Survey Response (after insert) that will go onto the correct Task Assessment record, catch the Change reference from there and then update your CHG with the according response values


Here is a short example:


(function executeRule(current, previous /*null when async*/) {



  var grTaskAssessment = new GlideRecord("task_assessment");


  if(grTaskAssessment.get("instance", current.getValue("instance"))) {



            var grChgReq = new GlideRecord("change_request");


            if(grChgReq.get("sys_id", grTaskAssessment.getValue("task"))) {


                      grChgReq.u_ra_complexity = current.getValue("response"); //u_ra_complexity is a field that I created for testing


                      grChgReq.update();


            } else {


                      gs.log("Survey response >> not << found.");        


            }


  } else {


            gs.log("Task >> not << found!");


  }



})(current, previous);



The only thing that you would need to come up with is a nice way of mapping the responses into the correct fields. Depending on how many Questions you have a mapping table might be helpful. That could contain a reference to the Question (since you have the sys_id of the question from the Survey response record) & the field name of the field that you want to map it against on the CHG table. Some proper debugging and logging would need to be added as well.


View solution in original post

4 REPLIES 4

fschuster
ServiceNow Employee
ServiceNow Employee

Hi Rhett,



Absolutely, but first of all I would ask: why? The answers are nicely displayed in the "Risk Assessment" related list on the CHG record already. Why would you duplicate those? It's pretty much one-click away.



However, if you would really have to do that you could do the following:


  • On the Task Assessment record you have two references:
    • One to the actual CHG record ("Task")
    • One to the Survey Instance ("Instance")
  • The table Survey Response [survey_response] holds all the answers to a specific Survey Instance (which is the same reference as on the Task Assessment)
  • Create a business rule on Survey Response (after insert) that will go onto the correct Task Assessment record, catch the Change reference from there and then update your CHG with the according response values


Here is a short example:


(function executeRule(current, previous /*null when async*/) {



  var grTaskAssessment = new GlideRecord("task_assessment");


  if(grTaskAssessment.get("instance", current.getValue("instance"))) {



            var grChgReq = new GlideRecord("change_request");


            if(grChgReq.get("sys_id", grTaskAssessment.getValue("task"))) {


                      grChgReq.u_ra_complexity = current.getValue("response"); //u_ra_complexity is a field that I created for testing


                      grChgReq.update();


            } else {


                      gs.log("Survey response >> not << found.");        


            }


  } else {


            gs.log("Task >> not << found!");


  }



})(current, previous);



The only thing that you would need to come up with is a nice way of mapping the responses into the correct fields. Depending on how many Questions you have a mapping table might be helpful. That could contain a reference to the Question (since you have the sys_id of the question from the Survey response record) & the field name of the field that you want to map it against on the CHG table. Some proper debugging and logging would need to be added as well.


rhett1
Tera Expert

Frank,



Sorry for the delayed response.   I was trying to understand how it worked for CHG, so I could replicate it for RISK in the GRC Module.   I like the risk assessment feature so much, I found it would useful for asking questions that would help one arrive at a risk-rating for the RISK module in GRC, which to me, makes sense.



Rhett


montanadawgz
Mega Contributor

I am trying to do this very similar. 

We have an Emergency Change Request, that CAB mgmt wants to route the workflow to a security officer if the 5th question is the task assessment = Yes.  I created a hidden field u_ciso_approval labeled CISO_approval (true/false), with default being false.  When the corresponding 5th security question in Risk Assessment is answered true, then I need to have a client script, business rule or calculated field to update the u_ciso_approval to a true value.   But can't get the client script to fire.  Any help would be appreciated.
Thanks

BOB S

Were you able to make this work?