Assessment Instance questions not getting created on assessment instance record

Hari1
Mega Sage

Hi,

I am creating assessments records on the assessment instance manually on submission of a catalog.
The catalog will have an attachment with the list of applications values.
I will be creating records on the assessment instance table for the list of applications.

The records are getting created in the assessment instance table but i do not see the questions (assessment instance questions) in them as per the attached snapshot.

a1.JPG

Workflow:

 

 

var attachSysId;

    var attach = new GlideRecord('sys_attachment');
    attach.addQuery('table_sys_id', current.sys_id);
    attach.query();
    if (attach.next()) {
        attachSysId = attach.getValue('sys_id');
    }
    var parser = new sn_impex.GlideExcelParser();
    var attachment = new GlideSysAttachment();

    // use attachment sys id of an excel file

    var getChoice = current.variables.please_select_the_application_type;
    var attachmentStream = attachment.getContentStream(attachSysId);

    parser.parse(attachmentStream);

    //Get the column headers
    var headers = parser.getColumnHeaders();
    var header1 = headers[0];

    while (parser.next()) {
        var row = parser.getRow();
        //Application Sys ID

        var appSysId = "87901fb2dbkay1546164a015ca961956";

        //Get Application Owner

        var appOwnrName;

        var appOwnr = new GlideRecord("cmdb_ci_business_app");
        appOwnr.addQuery("name", row[header1]);
        appOwnr.query();
        if (appOwnr.next()) {
            appOwnrName = appOwnr.getValue("it_application_owner");
        }

        //Create Assessment Group

        var asmtGroup = new GlideRecord('asmt_assessment');
        asmtGroup.initialize();
        asmtGroup.metric_type = appSysId;
        asmtGroup.sys_created_on = gs.nowDateTime();
        asmtGroup.insert();
        var asmtGroupNumber = asmtGroup.getValue('sys_id');

        //Create records on the assessment instance table 

        var ai = new GlideRecord('asmt_assessment_instance');
        ai.initialize();
        ai.metric_type = appSysId;
        ai.user = appOwnrName;
        ai.state = "ready";
        ai.assessment_group = asmtGroupNumber;
        ai.task_id = current.sys_id;
        ai.trigger_table = 'sc_req_item';
        ai.trigger_id = current.sys_id;
        ai.expiration_date = gs.nowDateTime();
        ai.insert();
}

 

 

 

0 REPLIES 0