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
Ruchi Gupta KeshriRuchi Gupta Keshri 

I am not able to delete Record in Salesforce Org B.....Please help where i am wrong? (Salesforce to Salesforce Integration)....Please Help

Hi all, I am doing Salesforce to Salesforce Integration...in Which If i am created and updated Lead in Org A then it will show successfully .i am done with GET,POST,PUT but not able to do Delete..
Callout Class in ORG A
@future(callout=true)
    global static void deleteLeadInSalesforceOrgB(set<Id> setLeIds){
        list<Lead> listLead= [SELECT Name,Company,Status,LeadSource,Phone FROM Lead LIMIT 1];
        system.debug('listLead'+listLead);
        Http http = new Http();
        HttpRequest request = new HttpRequest();
        request.setEndpoint('callout:SFDC_Org_B_Connect/services/apexrest/Leads'+setLeIds);
        request.setMethod('Delete');
        LeadWrapper leWr=new LeadWrapper();
        //leWr.idd =idd;
        request.setBody(JSON.serialize(leWr));
        //request.setHeader('Content-Type','application/json;charset=UTF-8'); 
        HttpResponse response = http.send(request);
        System.debug(response.getBody());
        // If the request is successful, parse the JSON response.
        if (response.getStatusCode() == 200) {
            String jsonStr = '{"feed":{"row_count":1,"items":[{"msg":"<a class=\\"keyword\\" href=http://abc.html>XYZ</a>Clicked<a class=\\"keyword\\" href=http://abc.html>http://abc.html</a>","interest":"Other","whendt":"2012-02-15T18:03:32-08:00"}]}}';
            LeadWrapper results = (LeadWrapper)JSON.deserialize(jsonStr, LeadWrapper.class);
            // for(object result : results){
            System.debug(response.getBody());
        }   
        else{
            system.debug(response.getStatusCode());
        }
    }
trigger condition
if(trigger.isbefore){
        if(trigger.isDelete){
            set<Id> leeIdSet=new set<Id>();
           // for(Lead le:){                
                leeIdSet=trigger.oldMap.keySet();  
                SalesforceConnect.deleteLeadInSalesforceOrgB(leeIdSet);
}}}

rest resource code in ORG B
 @HttpDelete
    global static string deleteLead() {
        RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;
        system.debug('req-->'+req);
        String idd = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
        system.debug('idd--->'+idd);
        Lead le = [SELECT ExternalId__c,id FROM Lead WHERE ExternalId__c = :idd LIMIT 1];
      //  le.id=idd;
        //system.debug('le---->'+le);
        delete le;
        return 'success';
    }
Please help me what i do..
PriyaPriya (Salesforce Developers) 

Hey Ruchi,

Are you getting any value in this ?
system.debug('idd--->'+idd);

Thanks,

Priya Ranjan

Ruchi Gupta KeshriRuchi Gupta Keshri
@Priya not getting any value