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

Salesforce Intergration Alert Echo

Mike Almon November 19, 2021

I have setup integration between Opsgenie and a Salesforce Developer Environment.  I want to retain the ability to open, update, or close an alert/case in 1 environment and it will change the corresponding alert/case in the other.  And for the most part that is working.

 

The 1 problem that I am seeing is when I create ticket in Opsgenie that creates a Salesforce case as expected, but the creation of Salesforce case triggers the creation of a new Opsgenie Alert.

 

The ideal sate:

New Opsgenie Alert -> Creates -> New Salesforce Case

New Salesforce Case -> Creates -> New Opsgenie Alert 

 

 

What I am Seeing:

New Opsgenie Alert -> Creates -> New Salesforce Case -> Creates -> New Different Opsgenie Alert 

New Salesforce Case -> Creates -> New Opsgenie Alert 

 

I did try to apply a filter to cont create alerts from Salesforce cases container the word Prometheus as most if not all alerts will be generated from Prometheus but it does not seem to work.  That is the only change made from the default configuration.

 

Screenshot from 2021-11-19 15-55-07.pngScreenshot from 2021-11-19 15-56-26.pngScreenshot from 2021-11-19 15-57-59.pngScreenshot from 2021-11-19 15-58-30.png

1 answer

1 accepted

1 vote
Answer accepted
Connor Eyles
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 22, 2021

Hi @Mike Almon 

We have reached out to the development team to gain a better understanding around this loop that seems to be happening, I will reply back once we get an update from the development team!

Thanks,

Connor

Connor Eyles
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 22, 2021

Hey @Mike Almon 

The following code block contains a minor change that passes the opsgenie-alias back to the Opsgenie. Can you please save the following as as opsgenieTrigger.apxt and use this file in your Sales force configuration and let me know how it goes!

 

trigger opsgenieTrigger on Case (after insert, after update) {
string endpoint = <OPSGENIE_API_URL>;
Case obj = Trigger.new[0];

string id=obj.Id;
string ownerId=obj.OwnerId;
boolean isDeleted = obj.IsDeleted;
string caseNumber = obj.CaseNumber;
string contactId = obj.ContactId;
string accountId = obj.AccountId;
string assetId = obj.AssetId;
string parentId = obj.ParentId;
string suppliedName = obj.SuppliedName;
string suppliedEmail = obj.SuppliedEmail;
string suppliedCompany = obj.SuppliedCompany;
string suppliedPhone = obj.SuppliedPhone;
string typeOfCase = obj.Type;
string status = obj.Status;
string reason = obj.Reason;
string origin = obj.Origin;
string subject = obj.Subject;
string description = obj.Description;
boolean isClosed = obj.IsClosed;
string priority = obj.Priority;
datetime closedDate = obj.ClosedDate;
boolean isEscalated = obj.IsEscalated;
boolean isClosedOnCreate = obj.IsClosedOnCreate;
datetime createdDate = obj.CreatedDate;
string createdById = obj.CreatedById;
datetime lastModifiedDate = obj.LastModifiedDate;
string lastModifiedById = obj.LastModifiedById;
datetime systemModstamp = obj.SystemModstamp;
string contactPhone = obj.ContactPhone;
string contactMobile = obj.ContactMobile;
string contactFax = obj.ContactFax;
string engineeringReqNumber = obj.EngineeringReqNumber__c;
string product = obj.Product__c;
string potentialLiability = obj.PotentialLiability__c;
string opsgenieAlias = obj.opsgenie_alias__c;

string payload= '{'+
'\"id\" :' + opsgenieClass.getPayloadStringByHandlingNull(id)+ ',' +
'\"ownerId\" :' + opsgenieClass.getPayloadStringByHandlingNull(ownerId )+ ',' +
'\"isDeleted\" :' + opsgenieClass.getPayloadStringByHandlingNull(isDeleted)+ ',' +
'\"caseNumber\" :' + opsgenieClass.getPayloadStringByHandlingNull(caseNumber)+ ',' +
'\"contactId\" :' + opsgenieClass.getPayloadStringByHandlingNull(contactId)+ ',' +
'\"accountId\" :' + opsgenieClass.getPayloadStringByHandlingNull(accountId)+ ',' +
'\"assetId\" :' + opsgenieClass.getPayloadStringByHandlingNull(assetId)+ ',' +
'\"priority\" :' + opsgenieClass.getPayloadStringByHandlingNull(priority)+ ',' +
'\"parentId\" :' + opsgenieClass.getPayloadStringByHandlingNull(parentId)+ ',' +
'\"suppliedName\" :' + opsgenieClass.getPayloadStringByHandlingNull(suppliedName)+ ',' +
'\"suppliedEmail\" :' + opsgenieClass.getPayloadStringByHandlingNull(suppliedEmail)+ ',' +
'\"suppliedCompany\" :' + opsgenieClass.getPayloadStringByHandlingNull(suppliedCompany)+ ',' +
'\"suppliedPhone\" :' + opsgenieClass.getPayloadStringByHandlingNull(suppliedPhone)+ ',' +
'\"typeOfCase\" :' + opsgenieClass.getPayloadStringByHandlingNull(typeOfCase)+ ',' +
'\"status\" :' + opsgenieClass.getPayloadStringByHandlingNull(status)+ ',' +
'\"reason\" :' + opsgenieClass.getPayloadStringByHandlingNull(reason)+ ',' +
'\"origin\" :' + opsgenieClass.getPayloadStringByHandlingNull(origin)+ ',' +
'\"subject\" :' + opsgenieClass.getPayloadStringByHandlingNull(subject)+ ',' +
'\"description\" :' + opsgenieClass.getPayloadStringByHandlingNull(description)+ ',' +
'\"isClosed\" :' + opsgenieClass.getPayloadStringByHandlingNull(isClosed)+ ',' +
'\"closedDate\" :' + opsgenieClass.getPayloadStringByHandlingNull(closedDate)+ ',' +
'\"isEscalated\" :' + opsgenieClass.getPayloadStringByHandlingNull(isEscalated)+ ',' +
'\"isClosedOnCreate\" :' + opsgenieClass.getPayloadStringByHandlingNull(isClosedOnCreate)+ ',' +
'\"createdDate\" :' + opsgenieClass.getPayloadStringByHandlingNull(createdDate)+ ',' +
'\"createdById\" :' + opsgenieClass.getPayloadStringByHandlingNull(createdById)+ ',' +
'\"lastModifiedDate\" :' + opsgenieClass.getPayloadStringByHandlingNull(lastModifiedDate)+ ',' +
'\"systemModstamp\" :' +opsgenieClass.getPayloadStringByHandlingNull(systemModstamp)+ ',' +
'\"contactPhone\" :' + opsgenieClass.getPayloadStringByHandlingNull(contactPhone) + ',' +
'\"contactMobile\" :' + opsgenieClass.getPayloadStringByHandlingNull(contactMobile)+ ',' +
'\"contactFax\" :' + opsgenieClass.getPayloadStringByHandlingNull(contactFax)+ ',' +
'\"engineeringReqNumber\" :' + opsgenieClass.getPayloadStringByHandlingNull(engineeringReqNumber)+ ',' +
'\"product\" :' + opsgenieClass.getPayloadStringByHandlingNull(product)+ ',' +
'\"potentialLiability\" :' + opsgenieClass.getPayloadStringByHandlingNull(potentialLiability)+',' +
'\"opsgenieAlias\" :' + opsgenieClass.getPayloadStringByHandlingNull(opsgenieAlias)+
'}';

opsgenieClass.xRESTCall(endpoint ,payload);


}

 

Thanks,
Connor

Mike Almon November 23, 2021

Hi Connor,

 

Thanks for the response it looks like salesforce is now improperly passing the opsgenie, it looks like the dashes (-) are being dropped somewhere when the echo happens

 

Order of what I am seeing

  1. New alert created in Opsgenie gets alias of 87becdae-5ff3-4b1f-b17d-33fe1a0ba44e-1637677705260
  2. Salesforce creates new case with the text field opsgenie_alias populated with 87becdae-5ff3-4b1f-b17d-33fe1a0ba44e-1637677705260
  3. Opsgenie creates new echo alert with alias of 87becdae5ff34b1fb17d33fe1a0ba44e1637677705260

 

Initial Opsgenie ticket:

Screenshot from 2021-11-23 09-53-34.png

 

Salesforce Case Created:

Screenshot from 2021-11-23 09-47-15.png

 

Opsgenie Echoed Ticket:

Screenshot from 2021-11-23 09-54-04.png

Connor Eyles
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 23, 2021

Hi @Mike Almon 

Thanks for getting back to me! Are you able to raise a ticket on this one? 

That way we can do a full investigation on the payload getting sent over from Salesforce to understand the issue at hand better.

You can go to https://support.atlassian.com/ to raise the ticket, ensure to link this community link in the ticket and I will keep an eye out for you in our queue :)

Thanks,

Connor

Mike Almon November 24, 2021

Hi Connor,

 

I found the issue that is causing the the drop dashes it is within the opsgenieClass.apxc that you provide, basically is filtering out all characters that are not alphanumeric or a space so I replaced

[^a-zA-Z0-9\\s]

with

[^a-zA-Z0-9\\s\\-]

at this line and it is now passing the opsgenie_alias propperly

https://github.com/opsgenie/opsgenie-integration/blob/11dbd3f30e3fdf1d19caea22ad91d569d870d244/salesForceServiceCloud/opsgenieClass.apxc#L14

Like # people like this
Connor Eyles
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 24, 2021

Hey Mike,

Awesome find :)

I'll pass this onto the development team to fix up, appreciate you sharing your findings here!

Thanks,

Connor

Like Steffen Opel _Utoolity_ likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events