• tmatthiesen
  • SMARTIE
  • 500 Points
  • Member since 2005

  • Chatter
    Feed
  • 19
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 146
    Replies

I'm puzzled

 

Running Eclipse Helios and Force.com IDE plug 20.0.1

 

  • On 2011-05-20, our Sandbox was on Spring 11.  If I used the IDE and did Run Tests on class Foo, I got a full debug log of the entire class execution in the Apex Test Runner view
  • On 2011-05-23, after our Sandbox was upgraded to Summer 11, running the exact same test in the IDE on class Foo yields a vastly truncated debug log in the Apex Test Runner view. The log is only about 130KB.

 

I know the code executes to completion because the same Run tests in the Force.com browser Apex Classes | Run Tests yields a debug log of 3300KB using the same log filters.

 

As far as I can tell, it is something about Summer 11 and how the Eclipse IDE version 20.0.1 obtains the debug log.

 

Any ideas greatly appreciated (I'm already filtering the log to LoggingLevel.INFO and thus avoiding the noise; but I need more than 130KB of debug log to analyze my execution).

 

 

Have an apex class that has been tested to work, but I am having problems understanding the documentation for creating a Scheduler class. The documentation here makes it seem like all I have to do is create the following scheduler class, but when I schedule it to run in salesforce nothing happens. Any help would be appreciated.

 

Scheduler Class

 

 

global class OppPoliceScheduler1 implements Schedulable{
	
   global void execute(SchedulableContext sc) {
   	
      OppPoliceController O = new OppPoliceController();
   }
}

 

 

Apex Class

 

 

public with sharing class OppPoliceController {
 
  public void Opportunity() {
 
     List<Opportunity> Opptys2 = [SELECT id, LastActivityDate, Activity_Status__c, StageName, (SELECT id, CreatedDate from Feeds ) FROM Opportunity WHERE StageName != 'Closed Won' AND StageName != 'Closed Lost' ORDER BY LastActivityDate DESC];
     
        for(Opportunity Op : Opptys2){
       
        datetime LastActivityDate = Op.LastActivityDate; //Last Activity Date in datetimeformat
        datetime CreatedDate = Op.Feeds[0].CreatedDate;  //Created Date in datetime format 
        
        
        date d = Date.Today();  //Current Date Formated
       
            if(LastActivityDate == null || d > LastActivityDate.addDays(14) || d > CreatedDate.addDays(14)) {
              
              Op.Activity_Status__c = 'High';
              
               
            }
            
            else if((d >= LastActivityDate.addDays(7) && d < LastActivityDate.addDays(14)) 
                     || (d >= CreatedDate.addDays(7) && d < CreatedDate.addDays(14))) {
         
               Op.Activity_Status__c = 'Medium';
               
               
            }
            
            else if(d < LastActivityDate.addDays(7) || d < CreatedDate.addDays(7)) {
                Op.Activity_Status__c = 'Low';
                
            }
            	
            else {
            
                Op.Activity_Status__c = 'Error';
                   
            }
        }    
      
           update Opptys2;
  }     
}

 

 

Hi,

 

I am new with Apex and, I was wondering if anyone can tell me what is wrong with the following code:

 

I was trying to compare the zip codes in the myset set with the BillingPostalCode of the account records.  Even though the code didn't give any errors, when I run it,  I get "maximum trigger depth exceeded" error. I guess  there is a problem with the loop and it is trying to run the same line over an over. 

 

 

trigger testtrigger on Account (After Insert, after update) {

Set<String> myset = new Set<String>{'87543','08502', '07541'}; 



String s = 'Tester'; 


for (Account accs : [select id, name,BillingPostalCode from account where BillingPostalCode in :myset]){ 
  


accs.Name = 'test successful';

update accs;

       }
    
}

 

Help will be  really appreciated.

Thanks!

 

I can schedule a job via Apex code:

 

System.schedule('test', '0 0 0 * * ?', new SchedulableClass());

 

The CronTrigger job doesn't have a "Name" field, so I can't query for the Job I just created.  This means I can't check to see if my job already exists calling System.schedule(); instead I just have to call "schedule()" and silently eat the exception it throws if the job already exists.

 

The only way you can figure out which CronTrigger is yours is to cache the return value of System.schedule(), which (it so happens) is the ID of the CronTrigger that is created.  However, you can't delete them from Apex:

 

 

Id jobid = System.schedule('test', '0 0 0 * * ?', new SchedulableClass());
delete new CronTrigger(Id = jobid);

// 'delete' throws 'DML not allowed on CronTrigger'

 

 

So the current state of Scheduled Jobs is:

 

You can create them from Apex Code, but not from the UI

You can delete them from the UI, but not from Apex Code

 

I guess that just seems odd to me.  Why did Salesforce create this whole new API (System.schedule()), with a seemingly random assortment of ways to manipulate it, instead of just exposing the CronTrigger table directly to the full range of DML operations?

 

Placing new functionality into new core objects, rather than new APIs, seems easier on everyone (the whole describe/global describe suite of API calls are an example of something that seems a natural fit for a set of read-only custom objects).

  • April 22, 2010
  • Like
  • 0

Hi,

 

I have created a Class that implements the Schedulable interface for a batch Apex class called batchable:

 

 

global class scheduledBatchable implements Schedulable{ global void execute(SchedulableContext sc) { batchable b = new batchable(); database.executebatch(b); } }

 

 Now I am not sure how I can write my test class... Can i call execute() ? What should be the SchedulableContext?

 

 

 

 

I received an email with the following inquiry:

 

Is there an easy way to determine the underlying SObject type when using objects that store polymorphic keys e.g. ProcessInstance? I tried the following :
 
for(ProcessInstance inst: [Select TargetObject.Id, Status, Id From ProcessInstance]){
                SObject sObj = inst.TargetObject;
                System.debug('>>>>>>>>>>>>>>>>>>>>>'+(sObj.getSObjectType()));
}
 
And I get this:
18.0 APEX_CODE,DEBUG;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;VALIDATION,INFO;WORKFLOW,INFO
8:6:22.566|EXECUTION_STARTED
8:6:22.566|CODE_UNIT_STARTED|[EXTERNAL]System Log Window
8:6:22.569|SOQL_EXECUTE_BEGIN|[1,27]|Aggregations:0|Select TargetObject.Id, Status, Id From ProcessInstance
8:6:22.574|SOQL_EXECUTE_END|[1,27]|Rows:4|Duration:5
8:6:22.574|METHOD_ENTRY|[3,1]|System.debug(String)
8:6:22.574|METHOD_ENTRY|[3,39]|SObject.getSObjectType()
8:6:22.574|METHOD_EXIT|[3,39]|getSObjectType()
8:6:22.574|USER_DEBUG|[3,1]|DEBUG|>>>>>>>>>>>>>>>>>>>>>Name
8:6:22.574|METHOD_EXIT|[3,1]|debug(ANY)
 
Do I have to use the "Id" prefix to determine what Object the record is associated with?

 

 

And the answer to this is that yes using the ID prefix is one way to do this but an easier one is to recognize that polymorphic relationships like  ProcessInstance.TargetObject and Event/Task.who/what point to the Name object. The name object has a convenient "Type" field which provides the sobject type information. So simply adding that field to the above query should provide the information required in this inquiry:

 

 

 

for(ProcessInstance inst: [Select TargetObject.Id, TargetObject.type, Status, Id From ProcessInstance]){
SObject sObj = inst.TargetObject;
System.debug('>>>>>>>>>>>>>>>>>>>>>'+(sObj.getSObjectType()));

System.debug('The Type for id: ' + sObj.id + ' is: ' + sObj.type);
}

 

Message Edited by mtbclimber on 03-08-2010 08:29 AM

Here's a bulk trigger I just wrote (I am new to this)... and it looks ok on paper. 

 

But when I add or update 1 record in the sandbox... the parent record remains unchanged.  Nothing happens... not even an incorrect answer.

 

Any thoughts?

 

Basic idea of the trigger is to update parent record (Student__c) when child records (Student_Call_Log__c) is changed.  I update the following fields on the Student__c object: call count, most recent call note and tech_support_log__c.

 

 

trigger Bulk_CallLogs on Student_Call_Log__c (after insert, after update) { // 1. Loop through Trigger.new & throw the relevent info in a list (either list of leads, list of lead id's, etc) // 2. Use the list to query related objects to populate another list // 3. Loop through the 2nd list to create a map of LeadID to related object // 4. Loop again through Trigger.new to add the related info to Lead using the map from #3 list<Student_Call_Log__c> list_thelogs = new list<Student_Call_Log__c>(); // list contains all of the logs being processed // Step 1 set <id> list_relatedstudents_temp = new set <id> (); for (Student_Call_Log__c log :list_thelogs) { list_relatedstudents_temp.add(log.related_student__c); } list<Student__c> list_relatedstudents = ([select id, Most_Recent_Call_Note__c, Tech_Support_Logs__c, Call_Count__c from Student__c where id IN :list_relatedstudents_temp]); // Step 2 list<Student_Call_Log__c> list_relatedlogs = ([select id, related_student__c, date__c, note__c from Student_Call_Log__c where related_student__c IN :list_relatedstudents order by Date__c DESC ]); list<Student_Call_Log__c> list_relatedlogs_mostrecent = ([select id, related_student__c, date__c, note__c from Student_Call_Log__c where related_student__c IN :list_relatedstudents order by Date__c DESC limit 1 ]); map<id, id> map_students = new map<id, id>(); map<id, date> map_log_date = new map<id, date>(); map<id, String> map_log_calltype = new map<id, string>(); map<id, String> map_log_callresult = new map<id, string>(); map<id, String> map_log_note = new map<id, string>(); map<id, Integer> map_log_counter = new map <id, integer>(); Integer counter = 1; //Step 3-A for (Student__c s :list_relatedstudents) { for (Student_Call_Log__c log :list_relatedlogs) { map_students.put(s.id, log.id); map_log_date.put(log.id, log.Date__c); map_log_calltype.put(log.id, log.Call_Type__c); map_log_callresult.put(log.id, log.Call_Results__c); map_log_note.put(log.id, log.note__c); map_log_counter.put(log.id, counter); } } //Step 4-A String temp_lognote = null; counter = 0; for (Student__c s :list_relatedstudents) { for (Student_Call_Log__c log :list_relatedlogs) { temp_lognote = temp_lognote + map_log_date.get(log.id) + ' -- ' + map_log_calltype.get(log.id) + ' -- ' + map_log_callresult.get(log.id) + ' -- ' + map_log_note.get(log.id) + '\n'; counter = counter + map_log_counter.get(log.id); } s.Tech_Support_Logs__c = temp_lognote; s.Call_Count__c = counter; temp_lognote = null; counter = 0; } //Step 3-B map<id, id> map_students_mostrecent = new map<id, id>(); map<id, string> map_log_mostrecentnote = new map<id, string>(); for (Student__c s :list_relatedstudents) { for (Student_Call_Log__c log :list_relatedlogs_mostrecent) { map_students_mostrecent.put(s.id, log.id); map_log_mostrecentnote.put(log.id, log.note__c); } } //Step 4-B for (Student__c s :list_relatedstudents) { for (Student_Call_Log__c log :list_relatedlogs_mostrecent) { s.Most_Recent_Call_Note__c = map_students_mostrecent.get(log.id); } } //Update records update list_relatedstudents; }

 

 

 

 

 

  • March 02, 2010
  • Like
  • 0

In the Spring '10 release notes (p128), the following feature is listed: 
 
 
Generic Collection Creations Now Supported
 
As of Spring '10, you can use generic sObjects to create a collection. For example, the following is now possible:
 
Set<Sobject> foo = new Set<Sobject>();
 
 
I tried this in a partner development edition org (on na7.salesforce.com) and it gets rejected when trying to compile in Eclipse.
 
 
Has anybody else been able to get this to work? 
  • February 15, 2010
  • Like
  • 0
Is Custom Settings 10MB counted as part of the Org Size Limit or is it added on top of the Org Size Limit? The documentation does not state anything regarding it. Thanks
Message Edited by NinoJose on 02-05-2010 01:41 AM

I have created a number of public custom settings - I really do want the settings to be public since I am using them to allow users to set options.  In my development org I define the settings as public.  When they are deployed to an other environment either through eclipse or the ant task, the custom setting is protected.

 

Is there a bug in the deployment tool?  When I look at the custom settings in the object in eclipse I see no reference to it being public so perhaps that is where the issue is.

 

Has anyone been able to successfully deploy public custom settings and if so, how did you do it?

 

Thanks,

 

Diane 

  • February 03, 2010
  • Like
  • 0

Hi,

 

    We have a trigger activated after update of account manager on account. In the trigger, it queries the old manager and put it to remove list. So when we do a bulk update of AM using Apex data uploader, error will occur when the update records is more than 20. Then we can only do it 20 at a time.

    I know there is a limitation of 20 SOQL queries trigger. But we do need to do the bulk update now and than. Do you have any solution to this?

 

    Thanks!

Does anyone know a scalable way to deploy Apex Code(in this case, I'm deploying triggers)?

I wrote a custom app and tested the code and everything was fine. I pushed the code to production and it was working and in use.

 
I wrote new code in our Sandbox later on for another process, when I ran a test of that code, I had enough coverage of it and I was ready to push that code to production as well. However, when I tried to move the new code to production using Eclipse, all of a sudden one of my old triggers that was already in production said it had 0% test coverage. This made my new migration fail. It was a trigger that I had already tested and it previously had 100% test coverage. Since you can't change triggers in production, it was extra baffling.

After a few hours of testing and spinning my wheels, I realized that in Production we had created a new validation rule that we didn't have in the Sandbox. Because of the new validation rule, the Test class that was previously working was not allowed to fire off one of my triggers thus invalidating a working triggers' code coverage (even though the trigger still functioned fine in production).

The moral of the story is that when you add any new code to production, it reruns a test of ALL your code (including previously added classes). If you've added anything in production that might affect some of your triggers, it can break your test coverage percentage.

 
Hello, 
 
In the example code below using DMLOptions the territory assignment will not refresh on update.  Has anyone else had any crack at this new functionality?
 
Also I have beforeInsert triggers being executed too, could it have any impacted the SOAP headers or do the DMLOptions get carried over in the trigger update?
 
 
Please advise,
 
Tom
 
 
--sample code-- 
 
 
 ...
 public sobject Obj
public PageReference Save() {
onSave=true;
system.debug(Obj);
        GeoAddress.writeto(Obj,useSecondaryAddress);
        
        //as of v.15 we can se the assignmentRuleHeader via APEX
        //this illiminates the need for a Ajax callback.
        Database.DMLOptions dmo = new Database.DMLOptions();
dmo.assignmentRuleHeader.useDefaultRule= true;
Obj.setOptions(dmo);
system.debug(dmo);
        
        update Obj;
        
       PageReference page = new PageReference('/'+objectId );
       page.setRedirect(true);
       return page;
    } 
 
debug log:
...
 
20090128205240.909:Class.ctrlAddressVerifier.Save: line 250, column 9: Account:{ShippingCountry=USA, ShippingStreet=1407 Blalock Rd, ShippingAddressAccuracy__c=L1AAA, ShippingCounty__c=Bogus County, Country__c=UNITED STATES, ShippingState=TX, ShippingFIPS__c=48201, Name=A-1 Paint Body Shop, SubRegion__c=United States, ShippingLatitude__c=29.79548000, Region__c=North America, ShippingCity=Houston, Id=0013000000Lyfx3AAB, ShippingPostalCode=77055-4413, ShippingLongitude__c=-95.52337300}
20090128205240.909:Class.Geography.GeoAddress.writeTo: line 371, column 13:     returning from end of method public void writeTo(SOBJECT:Account, Boolean) in 1 ms
20090128205240.909:Class.Geography.GeoAddress.writeTo: line 364, column 70:     returning from end of method public void writeTo(SOBJECT:Account, Boolean) in 2 ms
20090128205240.909:Class.ctrlAddressVerifier.Save: line 251, column 9:     returning from end of method public void writeTo(SObject, Boolean) in 2 ms
20090128205240.909:Class.ctrlAddressVerifier.Save: line 258, column 9: Database.DMLOptions:[AllowFieldTruncation=null, AssignmentRuleHeader=Database.DMLOptions.AssignmentRuleHeader:[AssignmentRuleId=null, UseDefaultRule=true], EmailHeader=null, LocaleOptions=null, OptAllOrNone=null]
20090128205240.909:Class.ctrlAddressVerifier.Save: line 260, column 9: Update: SObject
*** Beginning trigAccountCountryValidation on Account trigger event BeforeUpdate for 0013000000Lyfx3
  • January 28, 2009
  • Like
  • 0
Hi,

I had EmployeeBefore and EmployeeAfter triggers. I deleted them from Eclipse but how do I get rid of it in SF. I created a new trigger called EmployeeTrigger. When I run tests it is still executing those two deleted triggers along with Employee Trigger. So for some reason I need to delete it from Salesforce. Under src, I right clicked on Triggers and said save to server but it is still executing both before and after triggers.


Quick help would be appreciated.

thanks in advance,
kathyani
Hi,

I get how to use dynamic apex to find out about elements and fields in an sObject and how to leverage that information to prepare SOQL statements, but i'm having trouble figuring out how to dynamically access or assign a field value on a record using dynamic apex. Can someone please help? Say I want to create a method that receives an incoming sObject and changes the Name to be a concatenated string based on a supplied list of fields in the object itself or its parents. How would I do this?

When I try
sobj.Name = ...
I get the error 'Field expression not allowed for generic SObject'

I have a number of places where i'd like to be able to trigger essentially the same pattern of behavior on multiple objects types...

Thanks in advance.
  • November 12, 2008
  • Like
  • 0
Hello all:

I am writing a test method that exercises code that duplicates a parent object and its related children. I'm trying to exercise the part of the code that traps for errors inserting the new records. Here's the code I want to exercise
Code:
Savepoint sp = Database.setSavepoint();
  Database.SaveResult sr = Database.Insert (a, false);
        String err;
        
        String newRebateID = sr.getID();
        if ( !sr.isSuccess() ) {
         Database.rollback(sp);
         err = 'Failed to duplicate Rebate: '+this.rebateToClone.id;
         System.debug(err);
         Throw new SMART_Exception(err);
        }

 My strategy was simply to use System.runAs to run as user with insufficient permissions to insert these records. I create a new user on the fly with the appropriate profile, use System.runAs to "become" that user, and run the duplicate routine, all from my test class. I'd expect this to cause the Database.Insert command to return a null set, in which case I should see an exception, which should be caught and managed by this test code:
Code:
system.runas( paragoUser ) {
      Exception theException = null;
      try {
       clonedRebateId = duplicator.dupRebate(); 
      }
      catch ( Exception e ) {
       theException = e;
      }
      // these will throw NPE if the dupe succeeds, which it should not to pass test
      System.assertEquals( theException.getTypeName(), 'SMART_Exception' );
      System.assertEquals( theException.getMessage(), 'Failed to duplicate Rebate: '+ theReb.Id );
     }

 But no exception is thrown. To all appearances, the insert succeeds. I have verified that the relevant profile does not have create privs on either object. I'm using the "with sharing" keyword on both the test class and the class being tested.

Any ideas as to why the active profile doesn't seem to prevent my test from creating records?

Thanks,

Steve Lane

  • November 08, 2008
  • Like
  • 0
The Winter '09 docs don't seem to have anything about governor limits with the @future call other than the fact you can only invoke 200 @future methods/day/org. I know one of the goals of the @future notation is to allow us to get around the current apex governor limits without killing sf.com servers.

Does anyone know what the @future limits will be? We're thinking of new functionality that would fit into @future methods and want to get a sense of what we'll be dealing with in regard to limits.

Thanks,
Steve
HELP !!!
 
I have written a trigger to clone Account team members from a Parent account (into a subordinate account)  but cannot insert the team member privledges as I am getting the error "DML not permitted for UserAccountTeamMember object" !!!
 
What is the reason or approach I should use to do this?
 
 
 
 

When I dowload the latest Force.com IDE for Mac OS, and I try to extract the .tgz file using Archive Utility, I get an error:

 

Unable to expand "force.com-ide-installer-macosx.tgz" into "Downloads". (Error 1 – Operation not permitted.)

 

Doing tar -zvzf force.com-ide-installer-macosx.tgz in the Terminal results in:

 

force.com-ide-installer-macosx/configuration/install-content.bin: (Empty error message)
tar: Error exit delayed from previous errors.

 

What's up with that?

Hello,

I am not able to save my components or refresh my components from Server via Eclipse IDE for Force.com after I updated to Winter 12. I always get Connection Timeout exception. 

 

java.net.SocketTimeoutException: connect timed out
	at java.net.PlainSocketImpl.socketConnect(Native Method)
	at java.net.PlainSocketImpl.doConnect(Unknown Source)
	at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
	at java.net.PlainSocketImpl.connect(Unknown Source)
	at java.net.SocksSocketImpl.connect(Unknown Source)
	at java.net.Socket.connect(Unknown Source)
	at com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(Unknown Source)
	at sun.net.NetworkClient.doConnect(Unknown Source)
	at sun.net.www.http.HttpClient.openServer(Unknown Source)
	at sun.net.www.http.HttpClient.openServer(Unknown Source)
	at sun.net.www.protocol.https.HttpsClient.<init>(Unknown Source)
	at sun.net.www.protocol.https.HttpsClient.New(Unknown Source)
	at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(Unknown Source)
	at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
	at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
	at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(Unknown Source)
	at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(Unknown Source)
	at com.sforce.ws.transport.JdkHttpTransport.connectRaw(JdkHttpTransport.java:133)
	at com.sforce.ws.transport.JdkHttpTransport.connectLocal(JdkHttpTransport.java:97)
	at com.sforce.ws.transport.JdkHttpTransport.connectLocal(JdkHttpTransport.java:92)
	at com.sforce.ws.transport.JdkHttpTransport.connect(JdkHttpTransport.java:88)
	at com.sforce.ws.transport.SoapConnection.send(SoapConnection.java:94)
	at com.sforce.soap.metadata.MetadataConnection.describeMetadata(MetadataConnection.java:345)
	at com.salesforce.ide.core.remote.MetadataStubExt.describeMetadata(MetadataStubExt.java:303)
	at com.salesforce.ide.core.remote.MetadataStubExt.describeMetadata(MetadataStubExt.java:311)
	at com.salesforce.ide.core.remote.MetadataStubExt$$FastClassByCGLIB$$9404e285.invoke(<generated>)
	at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
	at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:700)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
	at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:77)
	at com.salesforce.ide.core.internal.aspects.MetadataOperationsRetryAspect.metadataOperationsRetry(MetadataOperationsRetryAspect.java:22)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:627)
	at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:616)
	at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:64)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:90)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
	at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:635)
	at com.salesforce.ide.core.remote.MetadataStubExt$$EnhancerByCGLIB$$c1ac1f9d.describeMetadata(<generated>)
	at com.salesforce.ide.core.services.MetadataService.getDescribeMetadata(MetadataService.java:54)
	at com.salesforce.ide.core.services.PackageDeployService.adjustDeployOptions(PackageDeployService.java:300)
	at com.salesforce.ide.core.services.PackageDeployService.deployWork(PackageDeployService.java:264)
	at com.salesforce.ide.core.services.PackageDeployService.deploy(PackageDeployService.java:144)
	at com.salesforce.ide.core.services.PackageDeployService.deploy(PackageDeployService.java:127)
	at com.salesforce.ide.core.services.PackageDeployService.deploy(PackageDeployService.java:111)
	at com.salesforce.ide.ui.actions.SaveToServerActionController.deploy(SaveToServerActionController.java:132)
	at com.salesforce.ide.ui.actions.SaveToServerActionController.saveResourcesToServer(SaveToServerActionController.java:114)
	at com.salesforce.ide.ui.actions.SaveToServerAction$1.execute(SaveToServerAction.java:63)
	at org.eclipse.ui.actions.WorkspaceModifyOperation$1.run(WorkspaceModifyOperation.java:106)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2344)
	at org.eclipse.ui.actions.WorkspaceModifyOperation.run(WorkspaceModifyOperation.java:118)
	at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)

 Please let me know if anyone has the similar problem.

 

i am running WIndows 7 professional, Eclipse Indigo R1 and have latest Force.com IDE plugin available.

 

 

Hello Guys,

 

We are having one huge class , which is around 1500 lines of code in it and contains only one method.

now when we are trying to add any new code in methhod it shows compile error as below 

 

Compile Error : Method exceeds maximum number of allowed op codes, please break this method into multiple ,smaller methods.

 

 

 

Does is there any limit for code length in class function.

 

 

Any help will be apritiated .

 

Thanks,

Bala

 

Hi,
last weekend, Tapp0 Sandbox was upgraded to Winter '12.We have a Flash/Flex File, which included a working Session login (working with Summer '11).
We're giving SessionId from Apex:

UserInfo.getSessionId();

 


to Flexmethod:

     	if (initsession_id != null) {
     		infotext.text = "Login via Session " + initserver_url.toString();
	     	lr.server_url = initserver_url + '/services/Soap/u/22.0';
	     	lr.session_id = initsession_id;
	     	exturl = initserver_url;
     	} else {
     		infotext.text = "Login via User";
     		
			lr.username = user;
			lr.password = pwd + token;

     		conn.serverUrl = "https://test.salesforce.com/services/Soap/u/22.0"; 
     	}
     	
     	lr.callback = new AsyncResponder(loginResult, loginFault);
     	conn.login(lr);

 

  

We receive no response from Salesforce, flexfile can't login. It's working fine with Username and Password+Token.

I hope you can help!

I'm puzzled

 

Running Eclipse Helios and Force.com IDE plug 20.0.1

 

  • On 2011-05-20, our Sandbox was on Spring 11.  If I used the IDE and did Run Tests on class Foo, I got a full debug log of the entire class execution in the Apex Test Runner view
  • On 2011-05-23, after our Sandbox was upgraded to Summer 11, running the exact same test in the IDE on class Foo yields a vastly truncated debug log in the Apex Test Runner view. The log is only about 130KB.

 

I know the code executes to completion because the same Run tests in the Force.com browser Apex Classes | Run Tests yields a debug log of 3300KB using the same log filters.

 

As far as I can tell, it is something about Summer 11 and how the Eclipse IDE version 20.0.1 obtains the debug log.

 

Any ideas greatly appreciated (I'm already filtering the log to LoggingLevel.INFO and thus avoiding the noise; but I need more than 130KB of debug log to analyze my execution).

 

 

I uploaded a class implementing the Database.batchable interface into our live environment. It ran with a couple of errors and I decided to remove it and go another route.

 

The problem is that I now seem to be unable to remove the class. I tried cleaning out the contents of the class, like thus:

 

 

global class CalcSummaryBatch {	
}

 

 

The class above saved successfully without any errors, but Salesforce still refuses to allow me to delete the class, or save it as Inactive.

 

Here's the error that I'm getting: "This apex class is referenced elsewhere in salesforce.com. Remove the usage and try again.: Apex Job - xxxxxxxxxxxxxxxxxxx."

 

Here's the log under Setup > Monitoring > Apex Jobs. I double-checked, and all jobs are at a Completed status:

(There are about 20 such messages as the one below, all with status "Completed", and all the Apex Job Ids are listed as why the class cannot be deleted, in the error above)

Action
 Submitted Date
Job Type
Status
Status Detail
Total Batches
Batches Processed
Failures
Submitted By
Completion Date
Apex Class
Apex Method
 <nothing listed here>
 4/10/2011 11:00 PM Batch Apex
Completed
 First error: Attempt to de-reference a null object 0 0 1 xxx 4/10/2011 11:00 PM CalcSummaryBatch  <nothing listed here>
...

I’m the developer of a package that has a heavy dependence on a scheduled Batch Apex job. The package currently runs in a dozen or so orgs, some of which have fairly large amounts of data. One org in particular has over 3 million records that are processed by the Batch Apex job.

 

Over the past 3 months, we’ve been encountering a lot of stability problems with Batch Apex.  We’ve opened cases for several of these issues, and they’ve been escalated to Tier 3 Support, but it consistently takes 2 weeks or more to get a case escalated, and then it can several more weeks to get a meaningful reply form Tier 3.

 

We really need to talk with the Product Manager responsible for Batch Apex. We asked Tier 3 to make that introduction, but they said they couldn’t. We’re trying to work with Sales to set up a discussion with a Product Manager, but so far, we haven’t had any luck there either. We’re hoping that a Product Manager might see this post and get in touch with us. We need to find out whether Batch Apex is a reliable-enough platform for our application.

 

Here are a few examples of the problems we’ve been having:

 

  • The batch job aborts in the start() method. Tier 3 Support told us that the batch job was occasionally timing out because its initial  query was too complex. We simplified the query (at this point, there are no WHERE or ORDER BY clauses), but we occasionally see timeouts or near timeouts. However, from what we can observe in the Debug Logs, actually executing the query (creating the QueryLocator) takes only a few seconds, but then it can take many minutes for the rest of the start() method to complete. This seems inconsistent with the “query is too complex” timeout scenario that Tier 3 support described.  (Case 04274732.)
  • We get the “Unable to write to ACS Stores” problem. We first saw this error last Fall, and once it was eventually fixed, Support assured us that the situation would be monitored so it couldn’t happen again. Then we saw it happen in January, and once it was eventually fixed, Support assured us (again) that the situation would be monitored so it couldn’t happen again. However, having seen this problem twice, we have no confidence that it won’t arise again. (Case 04788905.)
  • In one run of our job, we got errors that seemed to imply that the execute() method was being called multiple times concurrently. Is that possible? If so, (a) the documentation should say so, and (b) it seems odd that after over 6 months of running this batch job in a dozen different orgs, it suddenly became a problem.

 

  • We just got an error saying, “First error: SQLException [java.sql.SQLException: ORA-00028: your session has been killed. SQLException while executing plsql statement: {?=call cApiCursor.mark_used_auto(?)}(01g3000000HZSMW)] thrown but connection was canceled.” We aborted the job and ran it again, and the error didn’t happen again.
  • We recently got an error saying, “Unable to access query cursor data; too many cursors are in use.” We got the error at a time when the only process running on behalf of that user was the Batch Apex process itself. (Perhaps this is symptomatic of the “concurrent execution” issue, but if the platform is calling our execute() method multiple times at once, shouldn’t it manage cursor usage better?)
  • We have a second Batch Apex job that uses an Iterable rather than a QueryLocator. When Spring 11 was released, that Batch Apex job suddenly began to run without calling the execute() method even once. Apparently, some support for the way we were creating the Iterable changed, and even though we didn’t change the API version of our Apex class, that change caused our Batch Apex job to stop working. (Case 04788905.)
  • We just got a new error, "All attempts to execute message failed, message was put on dead message queue."

 

We really need to talk with a Product Manager responsible for Batch Apex. We need to determine whether Batch Apex is sufficiently stable and reliable for our needs. If not, we’ll have to find a more reliable platform, re-implement our package, and move our dozen or more customers off of Salesforce altogether.

 

If you’re responsible for Batch Apex or you know who is, please send me a private message so we can make contact. Thank you!

 

  • April 04, 2011
  • Like
  • 0

Have an apex class that has been tested to work, but I am having problems understanding the documentation for creating a Scheduler class. The documentation here makes it seem like all I have to do is create the following scheduler class, but when I schedule it to run in salesforce nothing happens. Any help would be appreciated.

 

Scheduler Class

 

 

global class OppPoliceScheduler1 implements Schedulable{
	
   global void execute(SchedulableContext sc) {
   	
      OppPoliceController O = new OppPoliceController();
   }
}

 

 

Apex Class

 

 

public with sharing class OppPoliceController {
 
  public void Opportunity() {
 
     List<Opportunity> Opptys2 = [SELECT id, LastActivityDate, Activity_Status__c, StageName, (SELECT id, CreatedDate from Feeds ) FROM Opportunity WHERE StageName != 'Closed Won' AND StageName != 'Closed Lost' ORDER BY LastActivityDate DESC];
     
        for(Opportunity Op : Opptys2){
       
        datetime LastActivityDate = Op.LastActivityDate; //Last Activity Date in datetimeformat
        datetime CreatedDate = Op.Feeds[0].CreatedDate;  //Created Date in datetime format 
        
        
        date d = Date.Today();  //Current Date Formated
       
            if(LastActivityDate == null || d > LastActivityDate.addDays(14) || d > CreatedDate.addDays(14)) {
              
              Op.Activity_Status__c = 'High';
              
               
            }
            
            else if((d >= LastActivityDate.addDays(7) && d < LastActivityDate.addDays(14)) 
                     || (d >= CreatedDate.addDays(7) && d < CreatedDate.addDays(14))) {
         
               Op.Activity_Status__c = 'Medium';
               
               
            }
            
            else if(d < LastActivityDate.addDays(7) || d < CreatedDate.addDays(7)) {
                Op.Activity_Status__c = 'Low';
                
            }
            	
            else {
            
                Op.Activity_Status__c = 'Error';
                   
            }
        }    
      
           update Opptys2;
  }     
}

 

 

Can some one please tell me how to write a Unit test class for the scheduler class below please.

Should i seperate class or can i write it in the same class with @IsTest notation. 

 

 

global class HF_Survey_OneMonth Implements Schedulable 
{
    
    global void execute(SchedulableContext sc)
    {
        sendSurvey();
    }
    
    
    
    public void SendSurvey()
    {
         // Get the most recently created config object.
         Config_Object__c config = [Select HFSurveyCode__c, Survey_Date__C, SOQL_Query__C from Config_Object__C 
                                    where Name ='HostFamily_Survey'];
         List<Opportunity> oppList = Database.query(config.SOQL_Query__c);
         
         
             List<Account> accList = new List<Account>();             
                   for(Opportunity opp:oppList)
                     {
                        if(opp.AccountId!= null)
                        {
                          Account acc = opp.Account;
                          if(acc.Survey_Code__c != String.valueOf(config.HFSurveyCode__c) || acc.Survey_Opp_Id__c != opp.Id)
                           {
                             string oppcode= opp.Id;
                             acc.Survey_Code__c = String.valueOf(config.HFSurveyCode__c); 
                             acc.Survey_Dt__c = config.Survey_Date__c;
                             acc.Survey_Opp_Id__c = oppcode.subString(0,15);
                           }  
                         accList.add(acc); 
                        }
                     }
                update accList;  
                          
     }
  }

 

 

 

I think the Spring '11 release changed the behavior of some batch apex classes depending on how queries are used. I am now getting the following exception in a batch apex class that I haven't touched in over a year:

 

System.QueryException: Aggregate query has too many rows for direct assignment, use FOR loop

 

From what I can tell this started happening after the Spring 11 update.

 

Here is the simple code to reproduce the issue:

 

global class BatchJob implements Database.Batchable<sObject>{

	public string query = 'select Id, Name, (Select Id from Contacts) from Account';

	global Database.QueryLocator start(Database.BatchableContext bc){
		return Database.getQueryLocator(query); 
	}
	
	global void execute(Database.BatchableContext bc, List<sObject> objects){
	 	List<Account> accts = new List<Account>();
	 	for(sObject s : objects){
	 		Account a = (Account)s;
	 		system.debug('Throw error...');
	 		system.debug(a.Contacts); //This will throw a 'silent' System.QueryException
	 	}
	}
	 
	global void finish(Database.BatchableContext bc){
		system.debug('All done.');	 
	}
}

And here is the test class:

 

@isTest
private class BatchBugTEST {

    static testMethod void myUnitTest() {
        Account acct = new Account(Name = 'test');
        insert acct;
        
	//create some contacts
	List<Contact> cons = new List<Contact>();
		
	Integer count = 0;
	for(Integer i = 0; i < 200; i++){
		cons.add(new Contact(AccountId = acct.Id, LastName = 'test' + i));
	}
	insert cons;
	system.debug(cons.size());
		
	//Setup batch job       
        BatchJob job = new BatchJob();
	job.query += ' where Id = \'' + acct.Id + '\'';
		 
	Test.startTest();
	Database.executeBatch(job);
	Test.stopTest();
    }
}

What is most concerning about this is the System.QueryException is "silent". What I mean by this is that the code keeps running as if no exception occurred. Usually when a system exception occurs everything comes to a screeching halt and errors are displayed as test failures on the results page. In the case the code continues and the only way to see the error is to locate it in the debug logs.

 

The only reason I caught this error was good unit tests with assertions. If I didn't have these I would have had no idea this class stopped working correctly. I will be submitting a support ticket but if anyone from salesforce can run the code above on a Winter 11 instance I would be interested what the results are.

 

-Jason

 

 

 

 

  • February 14, 2011
  • Like
  • 0

Hi,

Our corporation instance of salesforce enterprise has been updated to winter 11, however when I click on my user name and go to system log, the old system log appears.

 

What do I need to do in order to enable the new one?

 

Thanks in advance!

  • October 11, 2010
  • Like
  • 0

Anyone please give me some idea about how to execute code present within Catch block as part of test method.

Thanks a lot !!!

 

 

I'm trying to display some Standard object (Contracts, Products) data on the Customer portal. But as we cannot display those details directly on the customer portal, I was told that we can copy the data from that object and save it on a Custom Object and then display that.

 

But the problem is that I have contracts and products linked via a custom object already. What I want to do it first perform a query in Apex, and then save the result of that query on to a object (By save I mean copy and not save a reference) that I can then display on the customer portal.

 

I have tried using dynamic DML to do it, but then again, it wasn't working. Any other way?

  • July 20, 2010
  • Like
  • 0

Hi,

 

I am new with Apex and, I was wondering if anyone can tell me what is wrong with the following code:

 

I was trying to compare the zip codes in the myset set with the BillingPostalCode of the account records.  Even though the code didn't give any errors, when I run it,  I get "maximum trigger depth exceeded" error. I guess  there is a problem with the loop and it is trying to run the same line over an over. 

 

 

trigger testtrigger on Account (After Insert, after update) {

Set<String> myset = new Set<String>{'87543','08502', '07541'}; 



String s = 'Tester'; 


for (Account accs : [select id, name,BillingPostalCode from account where BillingPostalCode in :myset]){ 
  


accs.Name = 'test successful';

update accs;

       }
    
}

 

Help will be  really appreciated.

Thanks!