• Sujesh Ramachandran
  • NEWBIE
  • 5 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 8
    Replies

Hi All,

 

I have to do a real time integration in which whenever a opportunity status become closed Status, I want to send that opportunity and account details to another salesforce instance. But I also have to send all the attachement of accounts.

 

I have used Rest API to send the details from salesforce to another salesforce. But end up in Apex heap limit as the attchment size is very big.

 

Could you please suggest me which approach will be feasible in this scenario?

 

Thanks,

sujesh

 

Hi,

 

Could anyone guide me to create a report which displays a column as Case Comments Manager Name. 

 

Thanks,

Hi,

 

Could any one please tell me how to send attachments from one salesforce org to another with some other information.

 

Below is the scenario:

whenever a update happening in the oppurtunity. I wanted to send that oppurtunity details and attachments to another salesforce org.

 

Thanks,

Sujesh

Hi All,

 

Could anyone share the difference between @Httpput and @HttpPatch Rest Annotations.

 

Thanks,

Sujesh

Hi All,

 

Could anyone help.

is it possible to create Apex class at runtime using metadata api.

if possible please guide us.

 

Thanks,

Sujesh

I am trying to get basic profile info from Linkedin API in APEX, i got authorization token and secret token but not able to retrieve basic profile using the token. please find below the code :

 

public void getLinkedinData(){
    List<TestLinkedin__c> tok = [select unAuth_Key__c,unAuth_Token__c from TestLinkedin__c where name='AuthKey' limit 1];  
    oauth_token = tok[0].unAuth_Token__c;
    oauth_token_secret = tok[0].unAuth_Key__c;        

    unAuthorisedToken =  tok[0].unAuth_Token__c;
    unAuthorisedKey = tok[0].unAuth_Key__c;  

    nonceValue  = generateNonce(); 
    timeStamp = generateTimeStamp();     

    string TripItAccessDataUri='https://api.linkedin.com/v1/people/~/format/json';

    Http h = new Http();
    HttpRequest req = new HttpRequest();
    req.setMethod('GET');
    req.setEndpoint(TripItAccessDataUri);
    final String oAUth_BASE_signature = SignatureBaseStringForAccessData(TripItAccessDataUri,unAuthorisedToken,unAuthorisedKey,nonceValue,timeStamp); 
    String signature = SignatureForAccessData(oAUth_BASE_signature ,consumerKey_Secret+'&'+unAuthorisedKey);
    req.setHeader('Authorization','OAuth realm=\"https://api.linkedin.com/\",oauth_consumer_key=\"'+oauth_consumer_key+'\",oauth_token=\"'+unAuthorisedToken+'\",oauth_nonce=\"'+nonceValue+'\",oauth_token_secret=\"'+unAuthorisedKey+'\",oauth_signature_method=\"'+oauth_signature_method+'\",oauth_timestamp=\"'+timeStamp +'\",oauth_version=\"'+oauth_version+'\",oauth_signature=\"'+signature+'\"');  
    reqstr =oAUth_BASE_signature ;
    HttpResponse res = h.send(req);
    resData =  res.getBody();
    system.debug('&&&&&&&&&&&&&&&& Respose' + resData );
}   

public String generateNonce(){
    String nonce;
    String finalNonce ;  
    nonce = String.valueOf(Math.abs(Math.random())); 
    finalNonce = nonce.substring(nonce.indexOf('.')+1,nonce.length());
    System.debug('+++++++++Nonce '+ finalNonce );
    return finalNonce ;
} 
public long generateTimeStamp(){
    long millis = (long) System.currentTimeMillis() ;
    long sysTime = (long) millis / 1000;
    System.debug('+++++++++++++TimeStamp'+ sysTime );
    return sysTime ;
}

public String SignatureBaseStringForAccessData(String TripItAccessDataUri,String unAuthorisedToken,String unAuthorisedKey,String  nonceValue ,Long timeStamp) {
    String httpmethod = 'GET';
    String oAUTH_PARA='oauth_consumer_key='+oauth_consumer_key+'&oauth_nonce='+nonceValue +'&oauth_signature_method='+oauth_signature_method+'&oauth_timestamp='+timeStamp+'&oauth_token='+unAuthorisedToken+'&oauth_token_secret='+unAuthorisedKey+'&oauth_version='+oauth_version+'';
    String BASE_STRING = httpmethod+'&'+EncodingUtil.urlEncode(TripItAccessDataUri,'UTF-8')+'&'+EncodingUtil.urlEncode(oAUTH_PARA,'UTF-8');
    return BASE_STRING;
}

//Signature Generator for Data
public String SignatureForAccessData(String Signature_Base_Value,String Key){
    Blob mac = Crypto.generateMac('HmacSHA1',Blob.valueOf(Signature_Base_Value),Blob.valueOf(Key));
    String macUrl = EncodingUtil.urlEncode(EncodingUtil.base64Encode(mac),'UTF-8');
    System.debug('++++++++Final Signature Is '+macUrl );   
    return macUrl;
}

Response body:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<error>
    <status>401</status>
    <timestamp>1354429511382</timestamp>
    <request-id>GDGNWB2M1V</request-id>
    <error-code>0</error-code>
    <message>[unauthorized].OAU:tylg6udljqe0|e7820b33-6acc-4752-b014-f54d505cf‌8a0|*01|*01:1354376252:vufYE2Zeg9Dg/R1YXO21cRlfmPA=</message>
</error>
Hii  I am getting System.Limit Exception. Please any one help me out....


public static Transaction__c GenTransactionAnnuity(Integer unique, String policyFieldVal, String CUSIP)
    {

      User annuityUser =                 TestFactory.CreateUser(10+unique, 'Annuity External Wholesaler', 'Mouse');
      User forecareUser =                 TestFactory.CreateUser(11+unique, 'Annuity External Wholesaler', 'Dragon');
      insert annuityUser;
      insert forecareUser;

      Territory__c Annuitory =        TestFactory.CreateTerritory(10+unique, annuityUser.Id, 'Annuity', '♣WA0', '98000', '99000', 'WA', 'Independent');
      Territory__c Forecaritory =     TestFactory.CreateTerritory(11+unique, forecareUser.Id, 'Forecare', '♣WA1', '', '', 'WA', 'Independent');
     
     
      insert Annuitory;    ///// Getting exception Too many soql querries...
    
     
      insert Forecaritory;
     

      Account IndependentAccount = TestFactory.CreateAccount(10+unique, 'rigid', 'Active', 'Independent');
      insert IndependentAccount;

      Contact A = GenContactAnnuity(0+unique, false, 'Independent');
        A.Annuity_Territory__c = Annuitory.Id;
        A.Exclude_from_Territory__c = true; //so the trigger

      Contact F = GenContactForecare(2+unique, false, 'Independent');
        F.Forecare_Territory__c = Forecaritory.Id;
        F.Exclude_from_Territory__c = true; //so the trigger   
        List<Contact> contacts = new List<Contact>();
        contacts.add(A);
        contacts.add(F);
        insert contacts;

      Map<Id, Contact> contactMap = new Map<Id, Contact>([SELECT Annuity_Territory__c, Forecare_Territory__c FROM Contact WHERE Id =: A.Id OR Id =: F.Id]);
        A = contactMap.get(A.Id);
        F = contactMap.get(F.Id);     

      contacts = new List<Contact>([SELECT Annuity_Territory__c, Forecare_Territory__c FROM Contact WHERE Id =: A.Id]); ///// Getting exception Too many soql querries...

      Policy__c annuityPolicy = TestFactory.CreatePolicy(10+unique, A.id, CUSIP);
     
     
      insert annuityPolicy;
  • September 04, 2014
  • Like
  • 0

Hi All,

 

I have to do a real time integration in which whenever a opportunity status become closed Status, I want to send that opportunity and account details to another salesforce instance. But I also have to send all the attachement of accounts.

 

I have used Rest API to send the details from salesforce to another salesforce. But end up in Apex heap limit as the attchment size is very big.

 

Could you please suggest me which approach will be feasible in this scenario?

 

Thanks,

sujesh

 

Hi,

 

Could anyone guide me to create a report which displays a column as Case Comments Manager Name. 

 

Thanks,

Hi All,

 

Could anyone help.

is it possible to create Apex class at runtime using metadata api.

if possible please guide us.

 

Thanks,

Sujesh

I am trying to get basic profile info from Linkedin API in APEX, i got authorization token and secret token but not able to retrieve basic profile using the token. please find below the code :

 

public void getLinkedinData(){
    List<TestLinkedin__c> tok = [select unAuth_Key__c,unAuth_Token__c from TestLinkedin__c where name='AuthKey' limit 1];  
    oauth_token = tok[0].unAuth_Token__c;
    oauth_token_secret = tok[0].unAuth_Key__c;        

    unAuthorisedToken =  tok[0].unAuth_Token__c;
    unAuthorisedKey = tok[0].unAuth_Key__c;  

    nonceValue  = generateNonce(); 
    timeStamp = generateTimeStamp();     

    string TripItAccessDataUri='https://api.linkedin.com/v1/people/~/format/json';

    Http h = new Http();
    HttpRequest req = new HttpRequest();
    req.setMethod('GET');
    req.setEndpoint(TripItAccessDataUri);
    final String oAUth_BASE_signature = SignatureBaseStringForAccessData(TripItAccessDataUri,unAuthorisedToken,unAuthorisedKey,nonceValue,timeStamp); 
    String signature = SignatureForAccessData(oAUth_BASE_signature ,consumerKey_Secret+'&'+unAuthorisedKey);
    req.setHeader('Authorization','OAuth realm=\"https://api.linkedin.com/\",oauth_consumer_key=\"'+oauth_consumer_key+'\",oauth_token=\"'+unAuthorisedToken+'\",oauth_nonce=\"'+nonceValue+'\",oauth_token_secret=\"'+unAuthorisedKey+'\",oauth_signature_method=\"'+oauth_signature_method+'\",oauth_timestamp=\"'+timeStamp +'\",oauth_version=\"'+oauth_version+'\",oauth_signature=\"'+signature+'\"');  
    reqstr =oAUth_BASE_signature ;
    HttpResponse res = h.send(req);
    resData =  res.getBody();
    system.debug('&&&&&&&&&&&&&&&& Respose' + resData );
}   

public String generateNonce(){
    String nonce;
    String finalNonce ;  
    nonce = String.valueOf(Math.abs(Math.random())); 
    finalNonce = nonce.substring(nonce.indexOf('.')+1,nonce.length());
    System.debug('+++++++++Nonce '+ finalNonce );
    return finalNonce ;
} 
public long generateTimeStamp(){
    long millis = (long) System.currentTimeMillis() ;
    long sysTime = (long) millis / 1000;
    System.debug('+++++++++++++TimeStamp'+ sysTime );
    return sysTime ;
}

public String SignatureBaseStringForAccessData(String TripItAccessDataUri,String unAuthorisedToken,String unAuthorisedKey,String  nonceValue ,Long timeStamp) {
    String httpmethod = 'GET';
    String oAUTH_PARA='oauth_consumer_key='+oauth_consumer_key+'&oauth_nonce='+nonceValue +'&oauth_signature_method='+oauth_signature_method+'&oauth_timestamp='+timeStamp+'&oauth_token='+unAuthorisedToken+'&oauth_token_secret='+unAuthorisedKey+'&oauth_version='+oauth_version+'';
    String BASE_STRING = httpmethod+'&'+EncodingUtil.urlEncode(TripItAccessDataUri,'UTF-8')+'&'+EncodingUtil.urlEncode(oAUTH_PARA,'UTF-8');
    return BASE_STRING;
}

//Signature Generator for Data
public String SignatureForAccessData(String Signature_Base_Value,String Key){
    Blob mac = Crypto.generateMac('HmacSHA1',Blob.valueOf(Signature_Base_Value),Blob.valueOf(Key));
    String macUrl = EncodingUtil.urlEncode(EncodingUtil.base64Encode(mac),'UTF-8');
    System.debug('++++++++Final Signature Is '+macUrl );   
    return macUrl;
}

Response body:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<error>
    <status>401</status>
    <timestamp>1354429511382</timestamp>
    <request-id>GDGNWB2M1V</request-id>
    <error-code>0</error-code>
    <message>[unauthorized].OAU:tylg6udljqe0|e7820b33-6acc-4752-b014-f54d505cf‌8a0|*01|*01:1354376252:vufYE2Zeg9Dg/R1YXO21cRlfmPA=</message>
</error>

Hi ,

 

I am adding contact from account detailpage by clicking a button contact list I am showing in new window after saving I am closing this window and refreshing parent window.

 

Here is code :

 

<script language="JavaScript" type="text/JavaScript">
function Refresh(){
window.opener.location.href="/{!$CurrentPage.parameters.id}";
window.top.close();
}
</script>

 

<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!Save}" oncomplete="Refresh()"/>
</apex:pageBlockButtons>

 

it is working properly in chrome and fire fox but not working in IE any one can help me.

and in opera even window is closing.

 

Thank You !!!