Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How do I populate additional fields in a ServiceNow Incident?

Opsgenie's out of the box integration with ServiceNow currently populates the short description, description, and assignment group of an Opsgenie-created, ServiceNow incident. A lot of folks ask how to customize the web service script to populate additional fields in the ServiceNow incident, so I thought I'd write it up and share it with you all on the community. I'll talk about how to map the “Entity” field from the Opsgenie alert to the “Category” field of the ServiceNow incident.

 

You'll need to use the Opsgenie ServiceNow integration with action mapping configured for Opsgenie alerts to create ServiceNow incidents for this advice to work for you. 

 

Getting started 

  1. Setup the Opsgenie integration with ServiceNow according to our documentation.

  2. Ensure that the integration in Opsgenie is set up to create ServiceNow incidents from Opsgenie alerts. It will look like this: 

    image1.png
  3. Log in to ServiceNow as an admin, navigate to the Opsgenie application by searching “Opsgenie” in the “Filter Navigator” search bar.

    image2.png

  4. Click on the “Opsgenie Web Svc Create” - this is the Web Service that is executed to create an incident in ServiceNow when an alert is created in Opsgenie. That alert is sent to ServiceNow to create an incident.

    image3.png

  5. Click on the Opsgenie Web Svc Create Transform map at the bottom.

    image4.png

  6. This will bring you to the script that you can edit to customize workflows. In this example, we are editing it to map the value of the “Entity” field from the Opsgenie alert, to the “Category” field of the ServiceNow incident

    This is what the script will look like:

    defaultScript.png

  7. Add in the additional lines of code starting on line 4 in the script in ServiceNow, then click “Update”



    var alias = source.u_opsgenie_alert_alias;
    var alert = client.getAlertFromOpsGenie(alias);
    var getAlertResponse = new global.JSON().decode(alert);
    var opsgenieEntity = getAlertResponse.data.entity;
    log.warn("[OpsGenie Web Svc Create] entity is" + opsgenieEntity);
    target.category = opsgenieEntity;


    Here's context on what these additional lines of code are doing:

    Line 1 grabs the alias received from the Opsgenie alert
    Line 2 makes the Get Alert API call to Opsgenie using that alias to get the full alert details, and assigns it to a variable named “alert”
    Line 3 grabs the actual alert payload from the “alert” variable
    Line 4 grabs the value of the entity field from the payload, and assigns to a variable named “opsgenieEntity”
    Line 5 logs the value of the the entity field to the Warning logs in ServiceNow
    Line 6 sets the value of the ServiceNow incident’s “Category” field, as the value of the opsgenieEntity variable

    Note: Line 5 is optional - it just logs what the value of the entity field from Opsgenie. You can see these logs under “Warnings” in the System logs in ServiceNow. (Search for “Warnings” in the ServiceNow Menu search bar)




    The updated script is shown below, with lines 4-10 being the additional lines of code we added to handle mapping the “Entity” field from the alert, to the “Category” field of the incident.

    image5.png



    That’s it! Now if you create an alert in Opsgenie and populate the “Entity” field, it will create an incident in ServiceNow and the “Category” field of the ServiceNow incident will be populated with that value. 

    Let me know if you have any questions below! 

 

2 comments

Hi Team,

Could you please provide code or data for getting Priority,  Assigned To and Closed Date/Time from Opsgenie to Auto Update same fields in Incident ServiceNow.?
Any suggestions are greatly appreciated. I'm new to Opsgenie and struggling with above requriements.

Thank You,

Sumana

Hi Sumana,

Were you able to find a solution to get the Priority in SNOW from OG alert?

If yes, can you share this solution?

 

Thanks,

Raz

Comment

Log in or Sign up to comment
TAGS
Community showcase
Published in Opsgenie

Leveraging Atlassian’s Opsgenie and AWS Cloudformation Registry to stay ahead of incidents

In the past, managing IT infrastructure was a hard job. It required a lot of manual effort and it was hard to keep track of all the necessary information (monitoring, scalability etc). Thankfully, as...

1,773 views 0 10
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you