For the SFDC Integration I send out a call to an external application and receive a Success status in my debug log(I am logged in as myself). External application says they are getting multiple pings of “success” over and over for several minutes(5mins+).
FYI: SFDC sends SFDC Id to External Application and the External Application connects to SFDC using Integration user credentials and the WSDL to extract data.
To stop the multiple pings, I freeze the Integration user. In my apex code I have a try catch for when I send my http request, and have set a request timeout(120000) in case there is a timeout. When I go to Setup->Apex Jobs. I can see that the Integration user has a status of processing over and over. I have also noticed in my Debug log there are times when I see two separate callouts sending the same data to the same endpoint.
public class ProcessHandlerShowAccounts
{
public static boolean isAlreadyRun=false;
public class AccountParameter
{
@InvocableVariable(required=true)
public Id accountId;
@InvocableVariable(required=true)
public String name;
}
@InvocableMethod
public static void handleNewAccounts(AccountParameter [] accountParameters)
{
if(isAlreadyRun)
return;
webServiceCallOut(accountParameters[0].accountId,accountParameters[0].name);
isAlreadyRun=true;
}
@future(callout=true)
public static void webServiceCallOut(ID n, String a){
Http http = new Http();
HttpRequest req = new HttpRequest();
req.setTimeout(120000);
HttpResponse res = new HttpResponse();
req.setEndpoint('https://something/Accounts'+'?sfdcid='+n+'&operation='+a);
String username = 'hello';
String password ='123';
Blob headerValue = Blob.valueOf(username + ':' + password);
String authorizationHeader = 'BASIC ' + EncodingUtil.base64Encode(headerValue);
req.setHeader('Authorization', authorizationHeader);
req.setMethod('POST');
//Create a new Http object to send the request object
//a response object is generated as a result
try{
res = http.send(req);
}catch(System.CalloutException e){
System.debug('Callout error: '+ e);
System.debug(res.toString());
}
}
}
Here is the criteria in the process builder: Account: AND (OR(ISCHANGED( [Account].Name ),ISCHANGED([Account].BillingCity ), ISCHANGED([Account].BillingState ),ISCHANGED([Account].BillingStreet ) ,ISCHANGED( [Account].BillingCountry ),ISCHANGED([Account].BillingPostalCode ) ,ISCHANGED([Account].Site_Use_Code__c ),ISCHANGED([Account].Shipping_County__c ) ,ISCHANGED([Account].Phone),ISCHANGED([Account].Type ) ,ISCHANGED([Account].Industry ),ISCHANGED([Account].DUNS_Number__c ) ,ISCHANGED([Account].Taxpayer_Identification_Number__c ),ISCHANGED([Account].ES_Company_Code__c ),ISCHANGED([Account].Customer_Class__c ),ISCHANGED([Account].HQ_Internal_Customer__c ) ) , NOT(ISNULL([Account].Oracle_ERP_Account__c )), INCLUDES([Account].Business__c , 'something') )
Contact: AND (OR(ISCHANGED([Contact].FirstName ), ISNEW(), ISCHANGED([Contact].LastName), ISCHANGED([Contact].Department ),ISCHANGED([Contact].LastModifiedDate ) ,ISCHANGED([Contact].Title ),ISCHANGED([Contact].Phone ),ISCHANGED([Contact].Email ),ISCHANGED([Contact].OwnerId ) ) , NOT(ISNULL([Contact].Account.Oracle_ERP_Account__c )), INCLUDES([Contact].Account.Business__c, 'something') )