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.
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
Initial Opsgenie ticket:
Salesforce Case Created:
Opsgenie Echoed Ticket:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey Mike,
Awesome find :)
I'll pass this onto the development team to fix up, appreciate you sharing your findings here!
Thanks,
Connor
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.