function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ken BrillKen Brill 

Invocable Method not making call to Endpoint

We are moving from SugarCRM to Salesforce, For another month we are going to work Cases on SugarCRM so I need Salesforce to keep Account data synced up. I want new and updated Accounts sent to SugarCRM. So I have this APEX that I am calling from a flow.

public class httpSugarCRM {
@InvocableMethod(label ='Update Account on SugarCRM' description='Sends the Account as an update to SugarCRM')
    public static List<String> sugarAccountUpdate(List<String> sfid) {
        String data = '';
        List<String> returnVarList = new List<String>();
        //Load the Account Object
        Account account = [Select Id,OwnerId,Name,Description,ExternalSystemID__c,BillingStreet,BillingCity,BillingState,BillingPostalCode,ShippingStreet,ShippingCity,
                                    ShippingState,ShippingPostalCode,Shipping_Email__c,DealerID__c,Billing_ID__c,Dealer_Type__c,AuthorizedContactPhone__c,AuthorizedContactEmail__c,
                                    AuthorizedContactName__c,AuthorizedContactTitle__c,AuthorizedContactFax__c,dba__c,Organizational_Country__c,OrganizationalState__c,
                                    Full_Legal_Entity_Name__c,CoveredByALS__c,IsSuspended__c,Billing_Phone__c,Billing_Email__c,Billing_Contact__c,BillingContactID__c,
                                    Tax_Exemption__c,UcaaSMode__c,AssignedTerritory__c,SubAgentSubResellerof__c,PartnerLeadSource__c,SalesArea__c,Website,Abnormal_Commissions__c,
                                    Industry,AnnualRevenue,Fax,Phone,Alternate_Phone__c,ConfigurationCertification__c,OnlineSalesTraining__c,OwnerCertified__c,OwnerRecertification__c,
                                    Closing_Estimate__c,Dead_Updated__c,Ignore_Dealer_in_Report__c,Inactive__c,InvoicedOn__c,PaidforDemoKitOn__c,PaidforTrainingOn__c,
                                    Partner_Type__c,ShippedDemoKitOn__c,Signed_Agreement_On__c,Signed_NDA_On__c,Strategic_Partner__c,Timezone__c,Associated_RVP_ID__c,
                                    PartnerState__c,PaidInHouseSystemon__c,PaidMarketingPackageon__c
                                    from Account where id IN :sfid] ;
        System.debug(account.Name);
        data = JSON.serialize(account);
        System.debug(data);
        System.debug('Sending data');
        SendUpdateToSugarCRM(data);
        System.debug('Done sending data');
        returnVarList.add(account.name);
        return returnVarList;
      }
    
    @future(callout=true)
    public static void SendUpdateToSugarCRM(string data){
        System.debug('Sending data');
        //Initialize the URL
        String url='https://myserver.com/rest/v11_5/SalesforceAccounts';
        System.debug('url='+url);
        // Instantiate a new Http object
        Http h = new Http();
        // Instantiate a new HTTP request
        // Specify request properties such as the endpoint, the POST method, etc. 
        HttpRequest req = new HttpRequest();
        req.setEndpoint(url);
        req.setMethod('POST');
        req.setHeader('Content-Type', 'application/json');
        req.setBody(data);
    
        // Send the request, and return a response
        HttpResponse response = h.send(req);
        system.debug('response::'+response.getBody());
    }
}
I am told when it runs I should see 2 log entries but I only see 2 and I never see the call com in on the remote server.
Ken BrillKen Brill
If I run each part in isolation they both work perfectly.
Tanya fosilTanya fosil
For invocable actions that perform callouts, you can now add a callout attribute to the invocable Apex method annotation. With this information, a flow calling the action knows how to manage the transaction at run time. Where: This change applies to Lightning Experience and Salesforce Classic. (https://www.connectebt.us/)