Use SCOM alert owner to update 'Assigned to' in SNOW Incident

Hello,

I’m hoping someone can help me out. I’ve configured Cookdown Connection center for bidirectional flow between SCOM and ServiceNow. Now I’m trying to reflect the SCOM alert owner details in the ‘Assigned to’ field in a ServiceNow Incident. The default script can use the ‘Assigned to’ details to update Owner details in SCOM, but I’m struggling to find a way to do it the other way around.

(function updatescomAlert(incidentRecord, scomAlertRecord, scomAlertUpdatePayload) {
// The incident connected to this alert is available as incidentRecord
// The SCOM alert is available as scomAlertRecord
// The alertUpdates object is available to update any SCOM properties

// The alertId is used to link this to the alert in SCOM, don’t change this unless you know what your doing
// TYPE: string
scomAlertUpdatePayload.AlertId = scomAlertRecord.alertid.toString();

// TYPE: string
scomAlertUpdatePayload.TicketId = incidentRecord.number.toString();

// TYPE: string
scomAlertUpdatePayload.CustomField1 = incidentRecord.assignment_group.getDisplayValue();

// TYPE: string
scomAlertUpdatePayload.CustomField2 = incidentRecord.business_service.getDisplayValue();

// TYPE: string
scomAlertUpdatePayload.CustomField3 = incidentRecord.cmdb_ci.getDisplayValue();

// TYPE: string
scomAlertUpdatePayload.CustomField4 = incidentRecord.state.getDisplayValue();

// TYPE: string
// scomAlertUpdatePayload.CustomField5 = “Custom field data”

// TYPE: string
scomAlertUpdatePayload.Owner = incidentRecord.assigned_to.getDisplayValue();

// TYPE: int
// if(scomAlertRecord.resolutionstate != 255){
// scomAlertUpdatePayload.ResolutionState = 254;
//}
})(incidentRecord, scomAlertRecord, scomAlertUpdatePayload);

I’m not familiar with Java script, but I tried using this in script: “incidentRecord.assigned_to = scomAlertUpdatePayload.Owner;”, which didn’t work. I would appreciate for suggestions or workarounds.

Also, I’m wondering if it’s possible to use the Alert History Comments as Notes in the ServiceNow incident.

Thank you!

Hi 12ma,

And welcome to the community!

In Connection Center there are 3 types of script. Post Processing (for new incidents/tickets), Alert Updates (for going back to SCOM as you have there), and Task/Incident Updates (from SCOM to existing ticket).

If it’s a new ticket getting raised by SCOM you’ll want to use Post-Processing to set this field initially. If you’re using Object connections as well you may be able to use automatic assignment to get this to happen based on the CI/Object it matches.

If it’s an existing ticket and you want to keep things in sync you can use Task/Incident Updates to update that field if required.

Be aware that in SCOM the owner field is flat text and can be basically anything, where the Assigned To field in ServiceNow is a reference to the User table. So it will take more effort to validate the input from SCOM, and match it to the correct user. Make sure that you have appropriate fall-back actions.

The scripting options themselves are documented on Cookdowns support site here (Post Processing) and here (Task Updates) respectively.

Kind of related, I’d check out the SNGuru blog as well. Lots of tips and tricks for ServiceNow scripting!