Customizing the Major Incident Process Playbook

JenniferRah
Mega Sage
Mega Sage

I'm trying to add some fields to the MIM - Review Situation Activity in the Major Incident Process playbook. I was able to get it to add the fields I wanted, but it's showing the sys_ids for the Reference fields instead of the display value. Does anyone know where I can change that? I tried changing the fields from the field name (like cmdb_ci) to cmdb_ci.name (for example). But when I do that, it just won't show the field at all.

 

 

JenniferRah_1-1760121424160.png

 

Thanks in advance for your help! 

1 ACCEPTED SOLUTION

JenniferRah
Mega Sage
Mega Sage

I finally figured it out! The magic is in a script include called SOWMIMPlaybookUtil. I pulled the getReviewSituationCardContent function out of the SOWMIMPlaybookUtilSNC script include and customized it as below.

 

var SOWMIMPlaybookUtil = Class.create();
SOWMIMPlaybookUtil.prototype = Object.extendsObject(sn_sow_mim.SOWMIMPlaybookUtilSNC, {
    initialize: function() {},

    type: 'SOWMIMPlaybookUtil',

    getReviewSituationCardContent: function(table, sysId, fields) {
        var output = [];
        var recordGr = this._getRecordById(table, sysId);
        if (gs.nil(recordGr) || !recordGr.isValidRecord())
            return output;
        if (gs.nil(fields)) {
            output = [{
                "label": gs.getMessage("Business impact"),
                "value": {
                    "type": "html",
                    "value": gs.getMessage('[Empty]')
                }
            }, { //Add this section
                "label": gs.getMessage("Configuration Item"),
                "value": {
                    "type": "html",
                    "value": gs.getMessage('[Empty]')
                }//end added section
            }, {
                "label": gs.getMessage("Actions taken"),
                "value": {
                    "type": "html",
                    "value": gs.getMessage('[Empty]')
                }
            }];

            output[0].label = recordGr[this.TABLE.INCIDENT.FIELD.BUSINESS_IMPACT].getLabel();
            output[1].label = recordGr.cmdb_ci.getLabel(); //Add this line
            output[2].label = recordGr[this.TABLE.INCIDENT.FIELD.ACTION_TAKEN].getLabel();

            var businessImpact = String(recordGr[this.TABLE.INCIDENT.FIELD.BUSINESS_IMPACT]);
            if (!gs.nil(businessImpact)) 
                output[0].value.value = businessImpact;

			//added section for CI
            var ci = String(recordGr.cmdb_ci.getDisplayValue());
            if (!gs.nil(ci)) 
                output[1].value.value = ci;

            var activities = recordGr[this.TABLE.INCIDENT.FIELD.ACTION_TAKEN].getJournalEntry(1).trim().split("\n\n");
            if (gs.nil(activities[0]))
                return output;

            var lastNote = activities[0].split(" - ")[1].split("\n")[1];
            if (!gs.nil(lastNote)) 
                output[2].value.value = lastNote;
        } else {
            fields = fields.split(",");
            fields.forEach(function(field) {
                if (recordGr.isValidField(field))
                    output.push({
                        "label": recordGr[field].getLabel(),
                        "value": {
                            "type": "html",
                            "value": recordGr.getDisplayValue(field) || "--"
                        }
                    });
            });
        }
        return output;
    }
});

 

View solution in original post

2 REPLIES 2

pdurgapavan
Tera Contributor

Hi @JenniferRah ,

 

Could you please guide me how to add fields on the Review Situation Activity on MIM playbook. I have been trying but didn't find a way.

 

Thanks in Advance.

JenniferRah
Mega Sage
Mega Sage

I finally figured it out! The magic is in a script include called SOWMIMPlaybookUtil. I pulled the getReviewSituationCardContent function out of the SOWMIMPlaybookUtilSNC script include and customized it as below.

 

var SOWMIMPlaybookUtil = Class.create();
SOWMIMPlaybookUtil.prototype = Object.extendsObject(sn_sow_mim.SOWMIMPlaybookUtilSNC, {
    initialize: function() {},

    type: 'SOWMIMPlaybookUtil',

    getReviewSituationCardContent: function(table, sysId, fields) {
        var output = [];
        var recordGr = this._getRecordById(table, sysId);
        if (gs.nil(recordGr) || !recordGr.isValidRecord())
            return output;
        if (gs.nil(fields)) {
            output = [{
                "label": gs.getMessage("Business impact"),
                "value": {
                    "type": "html",
                    "value": gs.getMessage('[Empty]')
                }
            }, { //Add this section
                "label": gs.getMessage("Configuration Item"),
                "value": {
                    "type": "html",
                    "value": gs.getMessage('[Empty]')
                }//end added section
            }, {
                "label": gs.getMessage("Actions taken"),
                "value": {
                    "type": "html",
                    "value": gs.getMessage('[Empty]')
                }
            }];

            output[0].label = recordGr[this.TABLE.INCIDENT.FIELD.BUSINESS_IMPACT].getLabel();
            output[1].label = recordGr.cmdb_ci.getLabel(); //Add this line
            output[2].label = recordGr[this.TABLE.INCIDENT.FIELD.ACTION_TAKEN].getLabel();

            var businessImpact = String(recordGr[this.TABLE.INCIDENT.FIELD.BUSINESS_IMPACT]);
            if (!gs.nil(businessImpact)) 
                output[0].value.value = businessImpact;

			//added section for CI
            var ci = String(recordGr.cmdb_ci.getDisplayValue());
            if (!gs.nil(ci)) 
                output[1].value.value = ci;

            var activities = recordGr[this.TABLE.INCIDENT.FIELD.ACTION_TAKEN].getJournalEntry(1).trim().split("\n\n");
            if (gs.nil(activities[0]))
                return output;

            var lastNote = activities[0].split(" - ")[1].split("\n")[1];
            if (!gs.nil(lastNote)) 
                output[2].value.value = lastNote;
        } else {
            fields = fields.split(",");
            fields.forEach(function(field) {
                if (recordGr.isValidField(field))
                    output.push({
                        "label": recordGr[field].getLabel(),
                        "value": {
                            "type": "html",
                            "value": recordGr.getDisplayValue(field) || "--"
                        }
                    });
            });
        }
        return output;
    }
});