• sakshi Gandhi 8
  • NEWBIE
  • 15 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 4
    Questions
  • 14
    Replies
I have below JSON ,How can I send in my request using apex:

"objects":[
{
"fieldsToNull":["DefaultPaymentMethodId"],
"AccountNumber":"A00000036",
"Id":"2c92c0f95a4085a8015a41f4012d183e"
}
]
, "type":"Account"
Hello, I am inserting 60k records and trigger is showing Too many query rows exception. I am trying to achieve roll up summary through this trigger .Below is code


trigger FRB_updateExceptionField on Process_Adherence_Monitoring__c (after insert,after update,after delete) {
Set<id> accIdSet = new Set<id>();
       string FRBRecordTypeID = utility.getFRBProfileNameLabel();
       if(Trigger.isInsert){
            For(Process_Adherence_Monitoring__c pm1 : Trigger.new){
                accIdSet.add(pm1.Organization_Name__c);
            }
        }
        if(Trigger.IsUpdate || Trigger.Isdelete){
            For(Process_Adherence_Monitoring__c pm1 : Trigger.old){
                accIdSet.add(pm1.Organization_Name__c);
            }
        }
        
        List<Account> accUpdateListunderfrst = new List<Account>();
        List<Account> accUpdateListUnderScnd = new List<Account>();
        List<Account> accUpdateListUnderThird = new List<Account>();
        List<Account> accUpdateListUnderForth = new List<Account>();
        Map<id,Account> accMap = new Map<id,Account>([select id, Number_of_Exception__c,Number_of_exceptions_under_7_10_bucket__c,Number_of_exceptions_under_4_6_bucket__c,Number_of_exceptions_under_11_19_bucket__c from Account where id IN :accIdSet]);
       List<Account>listToUpdateFrstBcktExceptions = [select Id, Name, Number_of_Exception__c ,(select id,Account_Standing__c from Process_Adherence_Monitoring__r  where Status__C != 'Closed' AND  recordtypeId =: FRBRecordTypeID AND Account_Standing__c = '0-3 Days (Green - New Exception)' ) from Account where Id IN :accIdSet];
       if(listToUpdateFrstBcktExceptions .size()>0){
           for (Account acc: listToUpdateFrstBcktExceptions ){
                accMap.get(acc.Id).Number_of_Exception__c = acc.Process_Adherence_Monitoring__r.size();
                accUpdateListunderfrst.add(accMap.get(acc.Id));
            }
        }
        
        
        List<Account>listToUpdatesecondBcktExceptions = [select Id, Name, Number_of_Exception__c ,(select id,Account_Standing__c from Process_Adherence_Monitoring__r  where Status__C != 'Closed' AND  recordtypeId =: FRBRecordTypeID AND Account_Standing__c = '4-6 Days (Yellow - Outside Correction Timeframe)' ) from Account where Id IN :accIdSet];
        if(listToUpdatesecondBcktExceptions .size()>0){
            for (Account acc:listToUpdatesecondBcktExceptions  ) {
                accMap.get(acc.Id).Number_of_exceptions_under_4_6_bucket__c= acc.Process_Adherence_Monitoring__r.size();
                accUpdateListUnderScnd.add(accMap.get(acc.Id));
            }
        }
        
        List<Account>listToUpdatethrdBcktExceptions =  [select Id, Name, Number_of_Exception__c ,(select id,Account_Standing__c from Process_Adherence_Monitoring__r  where Status__C != 'Closed' AND  recordtypeId =: FRBRecordTypeID AND Account_Standing__c = '7-10 Days (Orange - Approaching Critical Timeframe)' ) from Account where Id IN :accIdSet];
        if(listToUpdatethrdBcktExceptions.size()>0){
            for (Account acc:listToUpdatethrdBcktExceptions ) {
                accMap.get(acc.Id).Number_of_exceptions_under_7_10_bucket__c= acc.Process_Adherence_Monitoring__r.size();
                accUpdateListUnderThird.add(accMap.get(acc.Id));
            }
        }
        
        List<Account>listToUpdatefrthBcktExceptions =[select Id, Name, Number_of_Exception__c ,(select id,Account_Standing__c from Process_Adherence_Monitoring__r  where Status__C != 'Closed' AND  recordtypeId =: FRBRecordTypeID AND Account_Standing__c = '11-19 Days (Red - Immediate Correction Required)' ) from Account where Id IN :accIdSet];
         if(listToUpdatefrthBcktExceptions.size()>0){
            for (Account acc: listToUpdatefrthBcktExceptions) {
                accMap.get(acc.Id).Number_of_exceptions_under_11_19_bucket__c= acc.Process_Adherence_Monitoring__r.size();
                accUpdateListUnderForth.add(accMap.get(acc.Id));
            }
        }
        if(accUpdateListunderfrst.size()>0){
             update accUpdateListunderfrst;
        }
        if(accUpdateListUnderScnd.size()>0){
             update accUpdateListUnderScnd;
        }
        if(accUpdateListUnderThird.size()>0){
             update accUpdateListUnderThird;
        }
        if(accUpdateListUnderForth.size()>0){
             update accUpdateListUnderForth;
        }
       

}

Please help
Hello,

​The only thing we need is to get the folder contents to display in our VF page.
See the below link, which shows how to retrieve details using Java but the same is not working in APEX.
 
http://stackoverflow.com/questions/8932469/how-can-i-non-recursively-browse-the-contents-of-a-directory-with-the-aws-s3-api
 
Any help will be greatly appreciated.

And below is my code returning all objects under bucket.But I need to get detail of specific object.

global with sharing class SalesForceAmazonWSGetContent{
 
    public void GetObject(){
      
       string timestamp = Datetime.now().format('EEE, dd MMM yyyy HH:mm:ss z','America/Denver');
        string bucket = mybucket;
        String key = 'key.....use your key';
        string method = 'GET';
        string foldername = 'myfolder';
        string secret = 'secret......use your secret';
        string stringToSign= method+'\n\n'+ '' +'\n'+ timestamp+'\n/'+bucket+'/'+foldername;
        Blob bsig = Crypto.generateMac('hmacSHA1',Blob.valueOf(stringToSign),Blob.valueof(secret));
        string Signature= EncodingUtil.base64Encode(bsig);
        HttpRequest req = new HttpRequest();
        req.setMethod(method);
        req.setHeader('Host','s3.amazonaws.com');
        req.setEndpoint('https://s3.amazonaws.com'+ '/'+ bucket+ '/' + foldername);
        Http http = new Http();
        req.setHeader('Authorization','AWS '+key+':'+signature);
        req.setHeader('Date',timestamp);
        
        HttpResponse res = http.send(req);
        system.debug('+++++Body is'+res.getBody());
       
    }
  
}
 
Hello,

I need to create folder under bucket on amazon s3 through REST webservice in salesforce .I am getting 503 as status code .Below is my REST class.Please do help

global with sharing class SalesForceAmazonWebservices{

 public void s3RestPut() { 
  
  String Date1 =  Datetime.now().formatGMT('EEE,   dd MMM yyyy HH:mm:ss z');
  String filename = 'test3';
  String bucketname = 'Bucket1';
  String Method = 'PUT';
  HttpRequest req = new HttpRequest();
  req.setMethod(method);

 
  
  req.setEndpoint('http://aws-us-west-2.amazon.com/s3/'+  bucketname + '/' + filename);
  req.setHeader('HOST','aws-us-west-2.amazon.com/s3/'); 
  req.setHeader('content-type', filename);
  req.setHeader('content-Encoding', 'base64');
  req.setHeader('Date',Date1);
 
 
  String stringToSign = 'PUT\n\n\n'+Date1+'\n/'+bucketname+'/'+filename + '/' ;  

  Blob mac = Crypto.generateMac('HMacSHA1', blob.valueof(stringtosign),blob.valueof('*******************'));

      String signature = EncodingUtil.base64Encode(mac);
   
        String authHeader = 'AWS'  + '**************' + ':' + signature  ;
        req.setHeader('Authorization',authHeader);  
        req.setBody(filename);
        Http http = new Http()
        HTTPResponse res = http.send(req);
        
    }
}
I have below JSON ,How can I send in my request using apex:

"objects":[
{
"fieldsToNull":["DefaultPaymentMethodId"],
"AccountNumber":"A00000036",
"Id":"2c92c0f95a4085a8015a41f4012d183e"
}
]
, "type":"Account"
Hello, I am inserting 60k records and trigger is showing Too many query rows exception. I am trying to achieve roll up summary through this trigger .Below is code


trigger FRB_updateExceptionField on Process_Adherence_Monitoring__c (after insert,after update,after delete) {
Set<id> accIdSet = new Set<id>();
       string FRBRecordTypeID = utility.getFRBProfileNameLabel();
       if(Trigger.isInsert){
            For(Process_Adherence_Monitoring__c pm1 : Trigger.new){
                accIdSet.add(pm1.Organization_Name__c);
            }
        }
        if(Trigger.IsUpdate || Trigger.Isdelete){
            For(Process_Adherence_Monitoring__c pm1 : Trigger.old){
                accIdSet.add(pm1.Organization_Name__c);
            }
        }
        
        List<Account> accUpdateListunderfrst = new List<Account>();
        List<Account> accUpdateListUnderScnd = new List<Account>();
        List<Account> accUpdateListUnderThird = new List<Account>();
        List<Account> accUpdateListUnderForth = new List<Account>();
        Map<id,Account> accMap = new Map<id,Account>([select id, Number_of_Exception__c,Number_of_exceptions_under_7_10_bucket__c,Number_of_exceptions_under_4_6_bucket__c,Number_of_exceptions_under_11_19_bucket__c from Account where id IN :accIdSet]);
       List<Account>listToUpdateFrstBcktExceptions = [select Id, Name, Number_of_Exception__c ,(select id,Account_Standing__c from Process_Adherence_Monitoring__r  where Status__C != 'Closed' AND  recordtypeId =: FRBRecordTypeID AND Account_Standing__c = '0-3 Days (Green - New Exception)' ) from Account where Id IN :accIdSet];
       if(listToUpdateFrstBcktExceptions .size()>0){
           for (Account acc: listToUpdateFrstBcktExceptions ){
                accMap.get(acc.Id).Number_of_Exception__c = acc.Process_Adherence_Monitoring__r.size();
                accUpdateListunderfrst.add(accMap.get(acc.Id));
            }
        }
        
        
        List<Account>listToUpdatesecondBcktExceptions = [select Id, Name, Number_of_Exception__c ,(select id,Account_Standing__c from Process_Adherence_Monitoring__r  where Status__C != 'Closed' AND  recordtypeId =: FRBRecordTypeID AND Account_Standing__c = '4-6 Days (Yellow - Outside Correction Timeframe)' ) from Account where Id IN :accIdSet];
        if(listToUpdatesecondBcktExceptions .size()>0){
            for (Account acc:listToUpdatesecondBcktExceptions  ) {
                accMap.get(acc.Id).Number_of_exceptions_under_4_6_bucket__c= acc.Process_Adherence_Monitoring__r.size();
                accUpdateListUnderScnd.add(accMap.get(acc.Id));
            }
        }
        
        List<Account>listToUpdatethrdBcktExceptions =  [select Id, Name, Number_of_Exception__c ,(select id,Account_Standing__c from Process_Adherence_Monitoring__r  where Status__C != 'Closed' AND  recordtypeId =: FRBRecordTypeID AND Account_Standing__c = '7-10 Days (Orange - Approaching Critical Timeframe)' ) from Account where Id IN :accIdSet];
        if(listToUpdatethrdBcktExceptions.size()>0){
            for (Account acc:listToUpdatethrdBcktExceptions ) {
                accMap.get(acc.Id).Number_of_exceptions_under_7_10_bucket__c= acc.Process_Adherence_Monitoring__r.size();
                accUpdateListUnderThird.add(accMap.get(acc.Id));
            }
        }
        
        List<Account>listToUpdatefrthBcktExceptions =[select Id, Name, Number_of_Exception__c ,(select id,Account_Standing__c from Process_Adherence_Monitoring__r  where Status__C != 'Closed' AND  recordtypeId =: FRBRecordTypeID AND Account_Standing__c = '11-19 Days (Red - Immediate Correction Required)' ) from Account where Id IN :accIdSet];
         if(listToUpdatefrthBcktExceptions.size()>0){
            for (Account acc: listToUpdatefrthBcktExceptions) {
                accMap.get(acc.Id).Number_of_exceptions_under_11_19_bucket__c= acc.Process_Adherence_Monitoring__r.size();
                accUpdateListUnderForth.add(accMap.get(acc.Id));
            }
        }
        if(accUpdateListunderfrst.size()>0){
             update accUpdateListunderfrst;
        }
        if(accUpdateListUnderScnd.size()>0){
             update accUpdateListUnderScnd;
        }
        if(accUpdateListUnderThird.size()>0){
             update accUpdateListUnderThird;
        }
        if(accUpdateListUnderForth.size()>0){
             update accUpdateListUnderForth;
        }
       

}

Please help
Hello,

​The only thing we need is to get the folder contents to display in our VF page.
See the below link, which shows how to retrieve details using Java but the same is not working in APEX.
 
http://stackoverflow.com/questions/8932469/how-can-i-non-recursively-browse-the-contents-of-a-directory-with-the-aws-s3-api
 
Any help will be greatly appreciated.

And below is my code returning all objects under bucket.But I need to get detail of specific object.

global with sharing class SalesForceAmazonWSGetContent{
 
    public void GetObject(){
      
       string timestamp = Datetime.now().format('EEE, dd MMM yyyy HH:mm:ss z','America/Denver');
        string bucket = mybucket;
        String key = 'key.....use your key';
        string method = 'GET';
        string foldername = 'myfolder';
        string secret = 'secret......use your secret';
        string stringToSign= method+'\n\n'+ '' +'\n'+ timestamp+'\n/'+bucket+'/'+foldername;
        Blob bsig = Crypto.generateMac('hmacSHA1',Blob.valueOf(stringToSign),Blob.valueof(secret));
        string Signature= EncodingUtil.base64Encode(bsig);
        HttpRequest req = new HttpRequest();
        req.setMethod(method);
        req.setHeader('Host','s3.amazonaws.com');
        req.setEndpoint('https://s3.amazonaws.com'+ '/'+ bucket+ '/' + foldername);
        Http http = new Http();
        req.setHeader('Authorization','AWS '+key+':'+signature);
        req.setHeader('Date',timestamp);
        
        HttpResponse res = http.send(req);
        system.debug('+++++Body is'+res.getBody());
       
    }
  
}
 
Hello,

I need to create folder under bucket on amazon s3 through REST webservice in salesforce .I am getting 503 as status code .Below is my REST class.Please do help

global with sharing class SalesForceAmazonWebservices{

 public void s3RestPut() { 
  
  String Date1 =  Datetime.now().formatGMT('EEE,   dd MMM yyyy HH:mm:ss z');
  String filename = 'test3';
  String bucketname = 'Bucket1';
  String Method = 'PUT';
  HttpRequest req = new HttpRequest();
  req.setMethod(method);

 
  
  req.setEndpoint('http://aws-us-west-2.amazon.com/s3/'+  bucketname + '/' + filename);
  req.setHeader('HOST','aws-us-west-2.amazon.com/s3/'); 
  req.setHeader('content-type', filename);
  req.setHeader('content-Encoding', 'base64');
  req.setHeader('Date',Date1);
 
 
  String stringToSign = 'PUT\n\n\n'+Date1+'\n/'+bucketname+'/'+filename + '/' ;  

  Blob mac = Crypto.generateMac('HMacSHA1', blob.valueof(stringtosign),blob.valueof('*******************'));

      String signature = EncodingUtil.base64Encode(mac);
   
        String authHeader = 'AWS'  + '**************' + ':' + signature  ;
        req.setHeader('Authorization',authHeader);  
        req.setBody(filename);
        Http http = new Http()
        HTTPResponse res = http.send(req);
        
    }
}
Hi, I would like to get some information or sample code about how to read an external file (ie. pdf file) which is located at AWS S3. I´ve already know there is a toolkit to do that, but I also found out that Amazon has deprecated SOAP for their services and it would be sooner or later when they decide not to support anymore new SOAP request (now for example they do it only in https calls and said they won't updgrade SOAP methods, according to their documentation).

Any help on this with some sample code would be appreciated.

Hi All,

 

I am facing an issue while trying to get the  bucket objects from amazon s3 using rest api.Could any one please help me out on this.

 

Following is my code:

 

string timestamp = datetime.now().formatGmt('EEE, d MMM yyyy HH:mm:ss Z');
string bucket = 'xyz';
string stringToSign='GET\n\n\n'+timestamp+'\n/'+bucket+'/';
Blob bsig = Crypto.generateMac('hmacSHA1',Blob.valueOf(stringToSign),Blob.valueof('xxxxxxxxxxxxxxxxxxxxx'));
string Signature= EncodingUtil.base64Encode(bsig);
HttpRequest req = new HttpRequest();
string endpoint = 'https://s3.amazonaws.com';
req.setMethod('GET');
req.setHeader('Host',bucket+'.'+'s3.amazonaws.com');
req.setEndpoint(endpoint);
Http http = new Http();
string AWSAccessKeyId='xxxxxxxxxxxxxxxx';
req.setHeader('Authorization','AWS '+AWSAccessKeyId+':'+signature);
req.setHeader('Date',timestamp);
HttpResponse res = http.send(req);
system.debug('Body is'+res.getBody());

 

I am getting the Signature mismatch error for the above code.Any guidence appreciated.

 

 

Thanks,

Raj

 

  • October 31, 2013
  • Like
  • 1