var a=new SNC.AssessmentCreation().createAssessments(inputs.quizsisid,'',inputs.usersysid); returns NO QUESTIONS

ALURU VISVA SA1
Tera Contributor

Please help me to assign a a quiz to particular user where i have quiz sis id and user sys id

1 ACCEPTED SOLUTION

Muralidharan BS
Mega Sage
Mega Sage

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

 

View solution in original post

4 REPLIES 4

Muralidharan BS
Mega Sage
Mega Sage

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

 

Thank you Murali it worked.

You've Welcome 🙂

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);