How to trigger smart assessment using script?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2025 10:20 AM
I have created a smart assessment template, I'm trying to trigger it using script.
I went thought this article: https://www.servicenow.com/docs/bundle/yokohama-governance-risk-compliance/page/product/assessment-e...
I have copied the code from "Trigger Smart Assessment" action, but I'm unable to trigger the assessment successfully. Maybe I'm entering inputs in wrong format or manner.
Here is the code below, that I'm using in background script to execute the smart assessment. Please check if I'm doing something wrong.
(function() {
var as = new GlideRecord('sn_smart_asmt_template');
as.addEncodedQuery('sys_id=e8f2aa2387352610acb7ea883cbb35e3');
as.query();
if (as.next()) {
var user = new GlideRecord('sys_user');
user.addEncodedQuery('u_number=EMP0083646');
user.query();
if (user.next()) {
try {
var inputs = {};
inputs['template_id'] = as; // GlideRecord of table: sn_smart_asmt_template
inputs['assessors'] = [user]; // List
inputs['requestor'] = user; // GlideRecord of table: sys_user
inputs['due_date'] = ''; // Due Date
inputs['duration'] = ''; // Duration
inputs['duplication_mode'] = ''; // Choice
inputs['assessment_group'] = ''; // GlideRecord of table: sn_smart_asmt_assessment_group
inputs['scope'] = [{
'table': 'cmdb_ci_business_App',
'record': '831ac4e613252200f93eb6004244b0f6'
}]; // Array.Object
// Start Asynchronously: Uncomment to run in background. Code snippet will not have access to outputs.
// sn_fd.FlowAPI.getRunner().action('sn_smart_asmt.trigger_smart_assessment_lite').inBackground().withInputs(inputs).run();
// Execute Synchronously: Run in foreground. Code snippet has access to outputs.
var result = sn_fd.FlowAPI.getRunner().action('sn_smart_asmt.trigger_smart_assessment_lite').inForeground().withInputs(inputs).run();
var outputs = result.getOutputs();
// Get Outputs:
// Note: outputs can only be retrieved when executing synchronously.
var assessment_group = outputs['assessment_group']; // Reference
var assessment_instances = outputs['assessment_instances']; // List
var status = outputs['status']; // Choice
} catch (ex) {
var message = ex.getMessage();
gs.error(message);
}
}
}
})();
I'm getting this error:
Time: 0:00:00.156 id: surfsedev_1[glide.0] primary_hash=-907155693 (connpid=1514006) for: SELECT sys_user0."sys_id" FROM sys_user sys_user0 WHERE sys_user0."u_number" = ?
Placeholders follow:
0 (10):EMP0083646
sys_id="245b250593466e107952b4edfaba10a4" sequence="197508cf2f20000001" level="2" source="com.glide.ui.ServletErrorListener" message="*** Script: Invalid GlideRecord input format found: no thrown error" sys_class_name="syslog" context_map="{"_page_name":"sys.scripts.do","_system_id":"app148164.bwi201.service-now.com:surfsedev169","_logged_in_user":"hrishabh.kumar","_scope":"global","_user":"hrishabh.kumar","_is_impersonating":"false","_session_id":"D771698593066E107952B4EDFABA100C","_txid":"e85b21419346"}"
*** Script: Invalid GlideRecord input format found: no thrown error
Thanks
0 REPLIES 0