- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-19-2020 11:32 AM
Please help me to assign a a quiz to particular user where i have quiz sis id and user sys id
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-19-2020 09:11 PM
Hi Sai,
You first have to add users in the metrics category, go to view survey > metric category > users.
Next, run the script, if there is no users in the metrics, it will result in no questions
The below script will trigger for all the users in the metric category,
var assess = (new SNC.AssessmentCreation()).createAssessments('sys id of survey');
For specific users in the metric category
var assess = (new SNC.AssessmentCreation()).createAssessments('sys id of survey','','sysidofuser');
For users not in metric category
You have to create a user in the category and then use the script to createassessment like below.
var createuser = new GlideRecord('asmt_m2m_category_user');
createuser.initialize();
createuser.metric_category = 'sys id of metric category not survey sys id';
createuser.user = 'user sys id'
createuser.insert();
var assess = (new SNC.AssessmentCreation()).createAssessments('survey sys id ','','user sys id');
gs.info(assess);
Kindly mark my response correct and helpful if my suggestion helped you,
Thanks
Murali

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-19-2020 09:11 PM
Hi Sai,
You first have to add users in the metrics category, go to view survey > metric category > users.
Next, run the script, if there is no users in the metrics, it will result in no questions
The below script will trigger for all the users in the metric category,
var assess = (new SNC.AssessmentCreation()).createAssessments('sys id of survey');
For specific users in the metric category
var assess = (new SNC.AssessmentCreation()).createAssessments('sys id of survey','','sysidofuser');
For users not in metric category
You have to create a user in the category and then use the script to createassessment like below.
var createuser = new GlideRecord('asmt_m2m_category_user');
createuser.initialize();
createuser.metric_category = 'sys id of metric category not survey sys id';
createuser.user = 'user sys id'
createuser.insert();
var assess = (new SNC.AssessmentCreation()).createAssessments('survey sys id ','','user sys id');
gs.info(assess);
Kindly mark my response correct and helpful if my suggestion helped you,
Thanks
Murali
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-19-2020 10:13 PM
Thank you Murali it worked.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-19-2020 10:47 PM
You've Welcome 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-02-2022 01:17 AM
Hi Murali,
we have a requirement in ITBM APM to trigger assessment to 5 section for 5 types (users may differ) on business application. created metric types and we are using custom business rule with this on demand API. but its triggering only one assessment.
could you help me with code. below is the code
(function executeRule(current, previous /*null when async*/ ) {
var instanceId;
var sourceId = [];
var grAssessble = new GlideRecord('asmt_m2m_category_assessment');
grAssessble.addQuery('assessment_record', current.getUniqueValue());
grAssessble.query();
while (grAssessble.next()) {
sourceId.push(grAssessble.getUniqueValue());
}
var grUser = new GlideRecord('cmdb_rel_person');
grUser.addEncodedQuery('ci=' + current.getUniqueValue());
grUser.query();
while (grUser.next()) {
if (grUser.user.active != 'false') {
if (grUser.type == '400855c887941910147e65709bbb35bc' (type sys_id) && (current.u_trigger_tha == 'all' || current.u_trigger_tha == 'business_alignment')) // Business Application Owner
{
instanceId = new SNC.AssessmentCreation().createAssessments('f9dc58cc8701911015bbc8ce8bbb3563'(assessment metric sys_id), sourceId.toString(), grUser.getValue('user'));
} else if (grUser.type == '03c430e9db18ec10485854904b961924' && (current.u_trigger_tha == 'all' || current.u_trigger_tha == 'architecture')) // architect{
instanceId = new SNC.AssessmentCreation().createAssessments('36c18e2687815d5015bbc8ce8bbb3589', sourceId.toString(), grUser.getValue('user'));
} else if (grUser.type == '01f8d14c87941910147e65709bbb3513' && (current.u_trigger_tha == 'all' ||
current.u_trigger_tha == 'c&p')) // C&P Focal
{
instanceId = new SNC.AssessmentCreation().createAssessments('50b26df687859d5015bbc8ce8bbb3564',
sourceId.toString(), grUser.getValue('user'));
} else if (grUser.type == 'caa8110c87941910147e65709bbb355e' && (current.u_trigger_tha == 'all' ||
current.u_trigger_tha == 'som')) // Ci owner
{
instanceId = new SNC.AssessmentCreation().createAssessments('bb97ad7287c59d5015bbc8ce8bbb35db',
sourceId.toString(), grUser.getValue('user'));
} else if (grUser.type == '11eb8fac8714dd10147e65709bbb35da' && (current.u_trigger_tha == 'all' ||
current.u_trigger_tha == 'apm')) // Portfolio Manager
{
instanceId = new SNC.AssessmentCreation().createAssessments('dbe9617687c59d5015bbc8ce8bbb35af',
sourceId.toString(), grUser.getValue('user'));
} else {
gs.addErrorMessage(grUser.user.name + " is inactive");
}
}
gs.addErrorMessage('instanceId ' + instanceId);
gs.addErrorMessage('sourceId ' + sourceId);
})(current, previous);