Has anyone scripted on "PagerDuty Inbound Field Rule"? trying to get some values from a payload

Rajini2
Mega Sage

I am working on Pagerduty integration, and I am trying to populate the incident fields using the "PagerDuty Inbound Field Rules". Payload has a bunch of data, just want to bring the CI name. I know JSON, but not sure to do that here.

 

Rajini2_0-1744225803984.png

 

1 ACCEPTED SOLUTION

mike_allgire
Giga Guru

We have to use the following PagerDuty webhook payload field string: data.first_trigger_log_entry.channel.details.host to get the string data, and since the Configuration item is a reference we have to use the Script to try and find the object. If you set something like the below up in the script, save and test with the payload, you should see a sys_id returned as opposed to the string data.

//The string data comes back as "value"
var host = value;
var ci = findCI('cmdb_ci_server', 'fqdn', host);
if(!ci)
   ci = findCI('cmdb_ci', 'name', host);
result = ci;

function findCI(qTbl, qFld, qVal){
     var gr = new GlideRecord(qTbl);
     gr.addQuery(qFld, qVal);
     gr.setLimit(1);
     if(gr.next()){
           return gr;
      }
      return false;
}

 

View solution in original post

1 REPLY 1

mike_allgire
Giga Guru

We have to use the following PagerDuty webhook payload field string: data.first_trigger_log_entry.channel.details.host to get the string data, and since the Configuration item is a reference we have to use the Script to try and find the object. If you set something like the below up in the script, save and test with the payload, you should see a sys_id returned as opposed to the string data.

//The string data comes back as "value"
var host = value;
var ci = findCI('cmdb_ci_server', 'fqdn', host);
if(!ci)
   ci = findCI('cmdb_ci', 'name', host);
result = ci;

function findCI(qTbl, qFld, qVal){
     var gr = new GlideRecord(qTbl);
     gr.addQuery(qFld, qVal);
     gr.setLimit(1);
     if(gr.next()){
           return gr;
      }
      return false;
}