• VenkataRaja
  • NEWBIE
  • 40 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 37
    Questions
  • 22
    Replies
Hi all,

I am getting this error when I call Tooling API from @future(Callout = true) method. I was set IP address in profile settings whatever provided by salesforce
http://help.salesforce.com/apex/HTViewSolution?id=000003652&language=en_US (http://help.salesforce.com/apex/HTViewSolution?id=000003652&language=en_US)

since I am getting same error. It is working good in my dev edition, but not working in my sandbox. 
This error I am getting, when I tried to get access_token from http callouts.
HttpRequest req1 = new HttpRequest();
        req1.setEndpoint('https://test.salesforce.com/services/oauth2/token');
        req1.setMethod('POST');
        req1.setHeader('Content-Type','application/x-www-form-urlencoded');
        req1.setBody('grant_type=password' +
            '&client_id=<ClientId_from ConnectedApps>' +
            '&client_secret=<Client Secret from ConnectedApp>' +
            '&username=<UserName>' +
            '&password=<Password>');
       
        Http http = new Http();
        HttpResponse response1 = http.send(req1);
       
        System.debug('BODY: '+response1.getBody());
getting error on hilighted.

Thanks 
Venkat

Hi,

I am Calling future method from schedule apex, getting an error: System.HttpResponse[Status=Unauthorized, StatusCode=401]
I think we are getting because of UserInfo.getSessionId() null, If I comment hilighted line also I am getting same error. Is there any solution for this. or Can I schedule the callouts?

public class Sample
{
      @future(Callout = true)
      public static void getCoverageforClasses()
      {
           String objectIdQuery = 'SELECT ApexClassorTriggerId, NumLinesCovered, NumLinesUncovered FROM ApexCodeCoverageAggregate';

           String environmentURL = URL.getSalesforceBaseUrl().toExternalForm() + '/services/data/v28.0/tooling/query/?q=' +      EncodingUtil.urlEncode(objectIdQuery, 'UTF-8');
     
        HttpRequest req = new HttpRequest();
        req.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionID());
        req.setHeader('Content-Type', 'application/json');
        req.setEndpoint(environmentURL);
        req.setMethod('GET');
     
        Http h = new Http();
        return h.send(req).getBody();             
      }
}



Thanks
Venkat
Hi all,

I am getting null UserInfo.getSessionId() in @future(Callout = true).
Can you please post any one alternate way to work code.


Thanks 
Venkat.
Hi All,

I have to query on ApexCodeCoverageAggregate. I tried like this, but not able to get the result, is there any one have sample codes on this can you please post it. I need how use these Tooling API Objects. Please post with sample class and procedure how to execute these.

I tried like below.

public class SampleClass
{
      public List<ApexCodeCoverageAggregate> getCoverage()
      {
                 List<ApexCodeCoverageAggregate> apexCodeCoverageList = [SELECT NumLinesCovered, NumLinesUncovered, ApexClassorTriggerId FROM ApexCodeCoverageAggregate];
                 System.debug('@@@:apexCodeCoverageList:  '+apexCodeCoverageList);
                 return apexCodeCoverageList;
      }
This code is not working.

Thanks
Venkat


Hi all,

I have to notify(Using apex to send an email) to system admin apex percentage used and avg code coverage for Org and code coverage for each individual class.

Can you please post any Idea.
User-added image
Hi All,

Salesforce will send an email to admin when apex program execution fails(line #no and error message, etc), for which type of error it will send an email.

Thanks
Venkat.
Hi ,

I am getting all custom object list from the orgainization, but I am getting historical data objects. I don't want those objects in my list.
Can you please help any one.

List<Schema.SObjectType> allObjectsList = Schema.getGlobalDescribe().values();
Set<String> customObjectsList = new Set<String>();
                                            
        for(Schema.SObjectType objType : listOfAllObjects)
        {           
            Schema.DescribeSObjectResult objectResult = objType.getDescribe();
            if(objectResult.isCustom() && !objectResult.isCustomSetting())
            {               
                customObjectsList.add(objectResult.getName());                                                                                           
            }
        }

In customObjectsList I am getting 'Historical Data' Objects like abc__c_hd. I don't want '_hd' objects.

Thanks 
Venkat
Hi
I have             
public abstract class A
{
          public Task newTask;
          public void createT(Id caseId, Id accountId)
          {
                  newTask = new Task();
                  //Intializing the values for task here.

                  methodX();
                  methodY();
            }
        
          public abstract void methodX();
          public abstract void methodY();
}

I need test class on this.

Please send any links or how to cover code coverage on this. It will help lot.

Thanks
Venkat
Hi,

I have batch class, will send email to perticular user in finish method. I am writing test class for this, and created one test user and getting class success and getting code coverage. As per standards, Is it required to test this in System.runAs()? If we create a test user in any test class is mandatory to use system.runAs(), In whcih situation we are able to use this method.
Hi,

I created one batch class and sending email to user in finish method. For this I created one test user in in test class.
My Question is ..... Is it required to test in user mode to execute this batch class?
and Is it required to use System.runAs() whenever we are using test user in test class every time? or is there any specific reason to use System.runAs()?


Thanks 
Venkat
Hi,

public static void notifyResult()
{
     Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
    mail.setToAddress(new String[] {mail@sample.com (mailto:{mail@sample.com)});
    mail.setHtmlBody('TestBody');
    mail.setSubject = 'Test Subject';
    Messaging.sendEmail(new Messaging.SingleEmailMessage[]{mail});
}

==========
Test Method
=========

private static testMethod void notifyResultTest()
{
   //I am intializing Data Here.
  
   Test.startTest();
   instance.notifyResult();
  
   //assert is passing here
   system.assertEquals(1, Limits.getEmailInvocations());
   Test.stopTest();

   //assert is failing here.
  system.assertEquals(1, Limits.getEmailInvocations());
}

*** But I am expecting assertion statement after stopTest. Can you please give some one answer.


Thanks
Venkat
Hi All,

I am getting this error in my approval test class. I had one trigger on approval process and I am writing test class for that trigger.
Whenever I am running test class I am getting this error.
Please help any one.

Thanks
Venkat
Hi,

public class CustomObjectsInPickListCntrl
{
public String val {get;set;}
      public void getName()
     {
         List<SCHEMA.SOBJECTTYPE> gd = Schema.getGlobalDescribe().Values();     
         List<String> customObjectList = new List<String>();
       
       for(Schema.SObjectType f : gd)
       {
                  
         
          Schema.DescribeSObjectResult res = f.getDescribe();
          if(res.isCustom())
          {
              if(!res.isCustomSetting())
              {                 
                  customObjectList.add(f.getDescribe().getName());
              }
          }
       }
          
     }
}

In the above code customObjectList has all custom objects

I have to get like this

for(SObject s : customObjectList){
     List<s> slist =  [Select Id LastModifiedDate from s];
}

If I wirte like this I will get SOQL Exception (100), so How I can do now. Please advice any one.
Hi,

public class CustomObjectsInPickListCntrl
{
public String val {get;set;}
      public void getName()
     {
         List<SCHEMA.SOBJECTTYPE> gd = Schema.getGlobalDescribe().Values();     
         List<String> customObjectList = new List<String>();
       
       for(Schema.SObjectType f : gd)
       {
                  
         
          Schema.DescribeSObjectResult res = f.getDescribe();
          if(res.isCustom())
          {
              if(!res.isCustomSetting())
              {                 
                  customObjectList.add(f.getDescribe().getName());
              }
          }
       }
          
     }
}

In the above code customObjectList has all custom objects

I have to get like this

for(SObject s : customObjectList){
     List<s> slist =  [Select Id LastModifiedDate from s];
}

If I wirte like this I will get SOQL Exception (100), so How I can do now. Please advice any one.
Hi,

public class CustomObjectsInPickListCntrl
{
public String val {get;set;}
      public void getName()
     {
         List<SCHEMA.SOBJECTTYPE> gd = Schema.getGlobalDescribe().Values();     
         List<String> customObjectList = new List<String>();
       
       for(Schema.SObjectType f : gd)
       {
                  
         
          Schema.DescribeSObjectResult res = f.getDescribe();
          if(res.isCustom())
          {
              if(!res.isCustomSetting())
              {                 
                  customObjectList.add(f.getDescribe().getName());
              }
          }
       }
          
     }
}

In the above code customObjectList has all custom objects

I have to get like this

for(SObject s : customObjectList){
     List<s> slist =  [Select Id LastModifiedDate from s];
}

If I wirte like this I will get SOQL Exception (100), so How I can do now. Please advice any one.
Hi, 
 
public class CustomObjectsInPickListCntrl
{
public String val {get;set;}
      public void getName() 
     { 
         List<SCHEMA.SOBJECTTYPE> gd = Schema.getGlobalDescribe().Values();      
         List<String> customObjectList = new List<String>();
        
       for(Schema.SObjectType f : gd) 
       { 
                   
          
          Schema.DescribeSObjectResult res = f.getDescribe();
          if(res.isCustom())
          {
              if(!res.isCustomSetting())
              {                  
                  customObjectList.add(f.getDescribe().getName()); 
              }
          }
       }
           
     } 
}

In the above code customObjectList has all custom objects

I have to get like this

for(SObject s : customObjectList){
     List<s> slist =  [Select Id LastModifiedDate from s];
}

If I wirte like this I will get SOQL Exception (100), so How I can do now. Please advice any one.

Hi,

 

      I have plan to pass the list variable into url.

 

Ex: List<Id> ids = new List<Id>();

 

Ids have some list of Ids.

 

public PageReference method(){

       PageReference pr = new PageReference('/VFPage?IdList='+ids);

       return pr;

}

 

can I use like this. And Can I use these list variable in VFPage page.

 

Regards

Venkat

Hi,

 

      I have plan to pass the list variable into url.

 

Ex: List<Id> ids = new List<Id>();

 

Ids have some list of Ids.

 

public PageReference method(){

       PageReference pr = new PageReference('/VFPage?IdList='+ids);

       return pr;

}

 

can I use like this. And Can I use these list variable in VFPage page.

 

Regards

Venkat

Hi,

 

       How can I implement Go to LIst All Link in related list. And when we press on that link it needs to show all records for that parent.

 

Thanks & Records

Venkat

Hi,

 

       How can I implement Go to LIst All Link in related list. And when we press on that link it needs to show all records for that parent.

 

Thanks & Records

Venkat

Hi all,

I am getting this error when I call Tooling API from @future(Callout = true) method. I was set IP address in profile settings whatever provided by salesforce
http://help.salesforce.com/apex/HTViewSolution?id=000003652&language=en_US (http://help.salesforce.com/apex/HTViewSolution?id=000003652&language=en_US)

since I am getting same error. It is working good in my dev edition, but not working in my sandbox. 
This error I am getting, when I tried to get access_token from http callouts.
HttpRequest req1 = new HttpRequest();
        req1.setEndpoint('https://test.salesforce.com/services/oauth2/token');
        req1.setMethod('POST');
        req1.setHeader('Content-Type','application/x-www-form-urlencoded');
        req1.setBody('grant_type=password' +
            '&client_id=<ClientId_from ConnectedApps>' +
            '&client_secret=<Client Secret from ConnectedApp>' +
            '&username=<UserName>' +
            '&password=<Password>');
       
        Http http = new Http();
        HttpResponse response1 = http.send(req1);
       
        System.debug('BODY: '+response1.getBody());
getting error on hilighted.

Thanks 
Venkat

Hi,

I am Calling future method from schedule apex, getting an error: System.HttpResponse[Status=Unauthorized, StatusCode=401]
I think we are getting because of UserInfo.getSessionId() null, If I comment hilighted line also I am getting same error. Is there any solution for this. or Can I schedule the callouts?

public class Sample
{
      @future(Callout = true)
      public static void getCoverageforClasses()
      {
           String objectIdQuery = 'SELECT ApexClassorTriggerId, NumLinesCovered, NumLinesUncovered FROM ApexCodeCoverageAggregate';

           String environmentURL = URL.getSalesforceBaseUrl().toExternalForm() + '/services/data/v28.0/tooling/query/?q=' +      EncodingUtil.urlEncode(objectIdQuery, 'UTF-8');
     
        HttpRequest req = new HttpRequest();
        req.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionID());
        req.setHeader('Content-Type', 'application/json');
        req.setEndpoint(environmentURL);
        req.setMethod('GET');
     
        Http h = new Http();
        return h.send(req).getBody();             
      }
}



Thanks
Venkat
Hi All,

I have to query on ApexCodeCoverageAggregate. I tried like this, but not able to get the result, is there any one have sample codes on this can you please post it. I need how use these Tooling API Objects. Please post with sample class and procedure how to execute these.

I tried like below.

public class SampleClass
{
      public List<ApexCodeCoverageAggregate> getCoverage()
      {
                 List<ApexCodeCoverageAggregate> apexCodeCoverageList = [SELECT NumLinesCovered, NumLinesUncovered, ApexClassorTriggerId FROM ApexCodeCoverageAggregate];
                 System.debug('@@@:apexCodeCoverageList:  '+apexCodeCoverageList);
                 return apexCodeCoverageList;
      }
This code is not working.

Thanks
Venkat


Hi all,

I have to notify(Using apex to send an email) to system admin apex percentage used and avg code coverage for Org and code coverage for each individual class.

Can you please post any Idea.
User-added image
Hi ,

I am getting all custom object list from the orgainization, but I am getting historical data objects. I don't want those objects in my list.
Can you please help any one.

List<Schema.SObjectType> allObjectsList = Schema.getGlobalDescribe().values();
Set<String> customObjectsList = new Set<String>();
                                            
        for(Schema.SObjectType objType : listOfAllObjects)
        {           
            Schema.DescribeSObjectResult objectResult = objType.getDescribe();
            if(objectResult.isCustom() && !objectResult.isCustomSetting())
            {               
                customObjectsList.add(objectResult.getName());                                                                                           
            }
        }

In customObjectsList I am getting 'Historical Data' Objects like abc__c_hd. I don't want '_hd' objects.

Thanks 
Venkat
Hi,

public static void notifyResult()
{
     Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
    mail.setToAddress(new String[] {mail@sample.com (mailto:{mail@sample.com)});
    mail.setHtmlBody('TestBody');
    mail.setSubject = 'Test Subject';
    Messaging.sendEmail(new Messaging.SingleEmailMessage[]{mail});
}

==========
Test Method
=========

private static testMethod void notifyResultTest()
{
   //I am intializing Data Here.
  
   Test.startTest();
   instance.notifyResult();
  
   //assert is passing here
   system.assertEquals(1, Limits.getEmailInvocations());
   Test.stopTest();

   //assert is failing here.
  system.assertEquals(1, Limits.getEmailInvocations());
}

*** But I am expecting assertion statement after stopTest. Can you please give some one answer.


Thanks
Venkat
Hi All,

I am getting this error in my approval test class. I had one trigger on approval process and I am writing test class for that trigger.
Whenever I am running test class I am getting this error.
Please help any one.

Thanks
Venkat
Hi,

public class CustomObjectsInPickListCntrl
{
public String val {get;set;}
      public void getName()
     {
         List<SCHEMA.SOBJECTTYPE> gd = Schema.getGlobalDescribe().Values();     
         List<String> customObjectList = new List<String>();
       
       for(Schema.SObjectType f : gd)
       {
                  
         
          Schema.DescribeSObjectResult res = f.getDescribe();
          if(res.isCustom())
          {
              if(!res.isCustomSetting())
              {                 
                  customObjectList.add(f.getDescribe().getName());
              }
          }
       }
          
     }
}

In the above code customObjectList has all custom objects

I have to get like this

for(SObject s : customObjectList){
     List<s> slist =  [Select Id LastModifiedDate from s];
}

If I wirte like this I will get SOQL Exception (100), so How I can do now. Please advice any one.
Hi, 
 
public class CustomObjectsInPickListCntrl
{
public String val {get;set;}
      public void getName() 
     { 
         List<SCHEMA.SOBJECTTYPE> gd = Schema.getGlobalDescribe().Values();      
         List<String> customObjectList = new List<String>();
        
       for(Schema.SObjectType f : gd) 
       { 
                   
          
          Schema.DescribeSObjectResult res = f.getDescribe();
          if(res.isCustom())
          {
              if(!res.isCustomSetting())
              {                  
                  customObjectList.add(f.getDescribe().getName()); 
              }
          }
       }
           
     } 
}

In the above code customObjectList has all custom objects

I have to get like this

for(SObject s : customObjectList){
     List<s> slist =  [Select Id LastModifiedDate from s];
}

If I wirte like this I will get SOQL Exception (100), so How I can do now. Please advice any one.

Hi All

 

              I am tryign to use like this. Can I Use this.

 

Select id, Name, (Select id,name,CreatedDate from Contact ORDER BY CreatedDate LIMIT 5) from Account.

 

How Can I use Limit With in the SubQuery Is it possible.

 

Regards

Venkat

Hi All

 

              I am tryign to use like this. Can I Use this.

 

Select id, Name, (Select id,name,CreatedDate from Contact ORDER BY CreatedDate LIMIT 5) from Account.

 

How Can I use Limit With in the SubQuery Is it possible.

 

Regards

Venkat

Hi,

 

         I want to display the report based on multipick list values. If I have multipick list values are A, AB, ABC, AC, BC. Then standard report display the group as same. A(1), AB(1) Like this but I want Individual filtering A(4), B(3) like this. Is there any possibility please tell me. Urgent

 

Thanks & Regards

Venkat

 

 

Hi,

 

         I want to display the report based on multipick list values. If I have multipick list values are A, AB, ABC, AC, BC. Then standard report display the group as same. A(1), AB(1) Like this but I want Individual filtering A(4), B(3) like this. Is there any possibility please tell me. Urgent

 

Thanks & Regards

Venkat

 

Hi,

I have a VisualForce page which I am opening it on click of a Custom Button on the Contract Object. I want to open this page in a new window without the address bar. I tried all the following options but it does not work-

1) Opening using JavaScript by configuring it in 'Edit Contract Custom Button' - window.open('apex/Wizard_Step1a?id={!Account.Id}','scrollbars=no,resizable=no,status=no,toolbar=no,menubar=no')
2) window.open('apex/Wizard_Step1a?id={!Account.Id}','_blank')
3) By giving the option 'Display in existing window without header and sidebar' and specifying the URL of the page as '/apex/Wizard_Step1a?id={!Account.Id}'

Can anyone please help me solve this issue?

Thanks,
Jina