Indicator template bulk creation + empty fields on Indicator

Mira1992
Kilo Sage

Hello community,

I have a request from the customer to create an Indicator Template for each Control Objective.
They have 250 Control Objectives and 14 613 Controls so I decided to go with the Fix Script.
It should create 250 Indicator Templates, create a relationship between the CO and Template in the sn_grc_m2m_ind_temp_cont table and this relationship should automaticaly create Indicators.

Demand is to automatically populate these fields on the Indicator template: name, short description, instructions, collection frequency, first run date and next run date.

My script creates 250 Indicator Templates, does the mapping and Indicators on the sn_grc_indicator table are created but ...

"Template" and the "first_run_date" fields on the Indicators are empty.

And I have no idea why as on the Template everything seems to be fine.
Would you know what might be the problem?
Thanks a lot for any help.

My fix script:

(function() {
    // Query the Control Objective table
    var prefix = 'Annual self-assessment - ';
    var html = '<p><span style="font-size: 10pt;"><strong>Instructions for Annual Self-Assessment</strong></span></p>\
        <p>Welcome to the annual self-assessment. Please follow these instructions carefully to ensure your compliance status is accurately reported.</p>\
        <p>&nbsp;</p>\
        <p><strong>Assessment Fields</strong></p>\
        <p><strong>Result:</strong></p>\
        <p>In this field, answer the question:&nbsp;<em>Are you compliant with the description/statement above?</em>&nbsp;Choose one of the following options:</p>\
        <p>&nbsp;</p>\
        <p><strong>&bull; Compliant:</strong> Fully compliant with the description above.</p>\
        <p><strong>&bull; Non-Compliant:</strong>&nbsp;Requirements from the description are not fully implemented.</p>\
        <p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &bull; &nbsp;Note: This response will create an issue for your entity. If an issue on the same underlying control already exists, your answer will be linked to the existing issue. The control will be marked as Non-Compliant.</p>\
        <p><strong>&bull; Not Applicable:&nbsp;</strong>Requirements do not apply to your site.</p>\
        <p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &bull; &nbsp;Note: You must specify why in the close notes.</p>\
        <p>&nbsp;</p>\
        <p><strong>Close Notes:</strong></p>\
        <p>Provide comments on your response. This is mandatory if you select &lsquo;Not Applicable.&rsquo;</p>\
        <p>&nbsp;</p>\
        <p><strong>Previous Assessments</strong></p>\
        <p>If you completed the self-assessment last year, your last year&rsquo;s result and close notes are attached at the top of this form for your reference.</p>\
        <p>&nbsp;</p>\
        <p>In&nbsp;the <strong>Name</strong>, you may find:</p>\
        <p>&bull; Reference to the IT/OT Policy</p>\
        <p>&bull; Control Category (Cat C / Cat B / Cat A): This indicates whether the control is basic (C) or advanced (B, A).&nbsp;</p>\
        <p>&nbsp;</p>\
        <p><strong>Context</strong></p>\
        <p>As part of the Information Security Assessment Process, you are required to complete a self-assessment. This serves as a basis for the IT &amp; OT Assessment performed by auditors at your plant. In years without an on-site assessment, or for Category C plants, this self-assessment indicates your compliance status.</p>\
        <p>&nbsp;</p>\
        <p>Your accurate and timely completion of this self-assessment helps keeping Information in Mondi safe.</p>';
    var controlObjectiveGR = new GlideRecord('sn_compliance_policy_statement');
    controlObjectiveGR.query();

    while (controlObjectiveGR.next()) {
        // Create a new Indicator Template record
        var indicatorTemplateGR = new GlideRecord('sn_grc_indicator_template');
        indicatorTemplateGR.initialize();
        indicatorTemplateGR.setValue('name', prefix + controlObjectiveGR.getValue('name'));
        indicatorTemplateGR.setValue('short_description', controlObjectiveGR.getValue('description'));
        indicatorTemplateGR.setValue('instructions', html);
        indicatorTemplateGR.setValue('collection_frequency', 'annually');
        indicatorTemplateGR.setValue('first_run_date', '2024-08-01');
        indicatorTemplateGR.setValue('next_run_time', '2025-01-01');


        var indicatorTemplateSysId = indicatorTemplateGR.insert();

        // Create a record in the m2m table to link the Control Objective and the Indicator Template
        if (indicatorTemplateSysId) {
            var m2mGR = new GlideRecord('sn_grc_m2m_ind_temp_cont');
            m2mGR.initialize();
            m2mGR.setValue('content', controlObjectiveGR.getUniqueValue());
            m2mGR.setValue('indicator_template', indicatorTemplateSysId);
            m2mGR.insert();
        }
    }
})();

Mira1992_0-1721226795521.png

 

1 ACCEPTED SOLUTION

MP12
Mega Guru

Hello @Mira1992 , the "first run date" is empty because this indicator has not been run yet. It will be filled after 1st execution (try by clicking on "Execute" in the indicator). 

Regarding the "template" field, can you check the user's role if he has right to see the indicator template record ? 

If the content of the indicator is the same for the 250, prefer to create the indicator template and attach it to the 250 control objectives. 

View solution in original post

1 REPLY 1

MP12
Mega Guru

Hello @Mira1992 , the "first run date" is empty because this indicator has not been run yet. It will be filled after 1st execution (try by clicking on "Execute" in the indicator). 

Regarding the "template" field, can you check the user's role if he has right to see the indicator template record ? 

If the content of the indicator is the same for the 250, prefer to create the indicator template and attach it to the 250 control objectives.