Triggering events from Salesforce


(David Hayes) #1

Here’s an example of us stretching Custom Event Transformers to handle XML from Salesforce. Since the raw events are XML with fairly regular tag names and formatting, we are able to parse them as strings.

We set up some logic in Salesforce to send all new deals to PagerDuty once they close, and the CET only creates events for ones above a certain size. The Product Manager on duty then needs to high-five the people involved in closing the deal (on Sales and in Product, Eng and Support).

Here’s essentially the code we use:

var raw = PD.inputRequest.rawBody.trim();

var id = /<sf:Id>(.+?)<\/sf:Id>/.exec(raw)[1];
var arrUpsell = /<sf:ARR_Upsell_Amount__c>(.+?)<\/sf:ARR_Upsell_Amount__c>/.exec(raw)[1];
var accountOwner = /<sf:Account_Owner_Name__c>(.+?)<\/sf:Account_Owner_Name__c>/.exec(raw)[1];
var opptyStage = /<sf:StageName>(.+?)<\/sf:StageName>/.exec(raw)[1];
var accountName = /<sf:account_name__c>(.+?)<\/sf:account_name__c>/.exec(raw)[1];

var description = "$" + arrUpsell + " ARR Upsell with " + accountName + " from " + accountOwner;

var normalized_event = {
  event_type: PD.Trigger,
  description: description,
  incident_key: id,
  client: "Salesforce",
  client_url: "" + id,
  details: {
    "Owner": accountOwner,
    "Stage": opptyStage,
    "Upsell": arrUpsell

if(arrUpsell>100000) {

Thanks @tai for the help with this one!

Is it possible to create an Event in SalesForce from PagerDuty
Implementing PagerDuty in combination with Salesforce Service Cloud and ServiceNow
(system) #2