Assign assessable records to the TPO

Community Alums
Not applicable

Good day folks!

 

I have an APM project and I have a related Application assessment. I will try to be detailed with the requirements:

I need to create a job  to automatically assign assessable records to the TPO for the business application specified in the assessable record.

 

The script should run on demand (not scheduled) and iterate through the evaluable records for a given metric type. The metric type should be hard coded, but a variable should be declared at the top of the script for ease of modification. We should use the sys_id of the metric type, rather than the name, to make it more explicit.

For each evaluable record in the Metric Type, the script will need to look up the Business Application using the Source ID.

Once the Business Application record is retrieved, get the sys_id of the user from the TPO field (it_application_owner) and assign the evaluable record to that user.

 

 

var AssignTPOToAssessableRecords = Class.create();
AssignTPOToAssessableRecords.prototype = {
    initialize: function() {
    },
   
    assignRecords: function(metricTypeSysId) {
        //var metricTypeSysId = 'your_metric_type_sys_id_here'; // Replace with the sys_id of your Metric Type

        // Query the assessable records with the specific Metric Type
        var assessableRecordGR = new GlideRecord('asmt_assessable_record');
        assessableRecordGR.addQuery('metric_type', metricTypeSysId);
        assessableRecordGR.query();
       
        while (assessableRecordGR.next()) {
            var businessAppGR = new GlideRecord('cmdb_ci_business_app');
            if (businessAppGR.get(assessableRecordGR.source_id)) {
                var tpoSysId = businessAppGR.it_application_owner;

                // If the TPO exists, assign the assessable record to the TPO
                if (tpoSysId) {
                    (new SNC.AssessmentCreation()).createAssessments(metricTypeSysId, businessAppGR.sys_id, tpoSysId);
                    // assessableRecordGR.setValue('assigned_to', tpoSysId);
                    // assessableRecordGR.update();
                }
            }
        }
    },

    type: 'AssignTPOToAssessableRecords'
};

Any idea how I should configure/schedule job code to make this work, or if there is a bug in my include script?

 

Any help is welcome. Sorry if it sounds laborious but I am a bit lost as this is my first time working with APM.

 

1 REPLY 1

Jonathan Schnei
Giga Guru

Hi Aram, 

 

Can you add some context to the use case / requirement? It looks like you are trying to assign the Assessment of a Business App for a specific Metric Type to the IT Application Owner with this script. But, the out of the box functionality already does this for you. I'll list the steps to do that below - but if this is not what you are intending, please elaborate in your response.

 

1. Navigate to the Metric Type you want to assess. Assessments > Metric Definition > Types. Select a metric type that applies to the Business App table. (there are 5 OOB - Business Value; Cloud Readiness; Customer Satisfaction; Function Fit; & Technical Risk)

2. In the Metric Type record, use the Conditions tab to filter which Business Apps assessments will be generated for

3. In the Metric Type record, use the Assessors tab to select the User field = IT Application owner / TPO (this ensures the assessments are assigned to the IT App Owner of the Business App being assessed)

4. Click the Generate Assessments box (note: you can first generate the assessable records with the related link, but Generate Assessments also does that while also generating the actual assessments)

5. IT App Owners will now see an assessment for the Metric Type you were on in Self-Service > My Assessments & Surveys. All Business Apps they own will be in the single assessment.

6. Repeat for each Metric Type you wish to assess Business Apps on.