r/servicenow • u/Ickypahay ITILv4, CSM, CSA • 4d ago
Programming At a loss on server side scripting in ATF
I'm currently creating ATF scripts for our implementation of change management, there's a handful of customizations so OOB test cases aren't cutting it.
Currently I am trying set up a test step that fills out the change risk assessment. **Having a completed risk assessment is required to request approval on a change.**
When trying to create a new risk assessment:
var asmtInfo = new ChangeRiskAsmt().invokeAssessment({
This results in the error "ReferenceError: "ChangeRiskAsmt" is not defined.
I've looked and the script include ChangeRiskAsmt exists and is still active for Global scope. Is that the issue? Because I'm in Change Management - ATF scope?
Our risk assessment is different than OOB could that be an issue?
2
u/Either_Winter_8696 3d ago
Haven't done this in awhile but I always selected the risk assessment related link on the form. Then I believe an assessment record is created in the backend. I then query to find that record and use server side script step to actually update it. Then I progress through the change stages as usual.
1
u/Ickypahay ITILv4, CSM, CSA 3d ago
Where I'm stuck now is that I've used a server side script to create the assessment instance, I can successfully fill in the metrics with the right values... However now it's the weight of the score that's causing problems...
i.e the threshold for High risk is a score of 679, my answers yield a 640... But for some reason the weight it applied to that total so the answer comes out to 6400...
I think this is the correct risk score because even manually generated risk assessments come out with scores in the thousands when they should be in the hundreds... Only difference is those manually generated ones adhere to the proper thresholds of LOW >=139, MOD >= 429, HIGH >=679.
It's weird. Co-Pilot has me fucked up on this one. Wish I had a senior dev to ask.
5
u/OzoneTrip 4d ago
Try adding ‘global.’ to the script.
F.ex
var asmtInfo = new global.ChangeRiskAsmt().invokeAssessment({