• sfdcKevinC
  • NEWBIE
  • 0 Points
  • Member since 2010

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

Hi,

 

I have an application on the AppExchange and several of my customers are complaining about very slow page loads or even page time outs. 

I did some debugging and found out that the following functions is causing the trouble. 

 

private List<SelectOption> cntcFlds;
public List<SelectOption> getContactFields() {
        
        if (cntcFlds == null) {
            List<SelectOption> options = new List<SelectOption>();
            options.add(new SelectOption('N/A','N/A'));
            Map<String, Schema.SObjectField> M = Schema.SObjectType.Contact.fields.getMap();
            for (Schema.SObjectField field: M.values()) {
                Schema.DescribeFieldResult F = field.getDescribe();
                if (F.isUpdateable()) {
                    options.add(new SelectOption(F.getName(),F.getLabel()));        
                }
            }
            cntcFlds = options;
            return options; 
        } else return cntcFlds;
        
    }

 

 But what is wrong with this function? Or did Salesforce changed the performance of the getDescribe functions?

 

Thanks,

Sten

 

 

 

  • June 08, 2012
  • Like
  • 0

Hi All,

 

Sorry this is long one - been hard at this since my last post. Very close, now stumped as something just doesn't added up!

 

 

This is strange - the following query works fine

 

 

select Id, Name, Accreditations__c 
 	 				
					from Account where 	Type = 'Dealer' 
 	 				
 	 				AND Country_ISO_Code__c = 'CH'
 	 				AND Accreditations__c includes ( 'RAP','REX' ) 
 	 				AND Accreditations__c != null

 

Note: Searching for RAP or REX.

 

Now inside my class I am doing this:

 

 

String stEndorsements;
	String stMulti;
	public String getStEndorsements(){
	
		stMulti = lead.All_Accreditation_Endorsements__c;
		stEndorsements = queryString();
		return stEndorsements;
	}
	

	
	public String queryString(){
		
		String[] newList = stMulti.split(';');
    	String newString = '';

   		for (Integer i = 0; i < newList.size(); i++){
      	
      		if (newList.size() != (i+1)){
      			newString +=  '\'' + newList[i] + '\',' ;
      		}
 
      		else {
        	newString +=  '\'' + newList[i] + '\'' ;
      		}


   		}
		return newString;
		
	}
	

 

 

Now this works fine too, checked through EA and using System.Debug

 

Here is where it's called

 

 

List<Account> accs = new List<Account>();
 	 		String prodcode = getProductCode();
 	 		
 	 		if (prodcode==null){
 	 		
 	 			getStEndorsements();
 	 			
 	 			String endor = stEndorsements;
 	 			
 	 			System.debug('DEBUG ERROR = '+endor);
 	 			
 	 			List<Account> fromLead = [select Id, Name, BillingCity, Country_ISO_Code__c, Owner.Name, Type, Accreditations__c 
 	 				
					from Account where 	Type = 'Dealer' 
 	 				
 	 				AND Country_ISO_Code__c =: lead.Country_ISO__c
 	 				AND Accreditations__c includes (: endor ) 
 	 				AND Accreditations__c != null
 	 				
 	 				LIMIT 1000];
 	 				
 	 				accs = fromLead;
 	 				
 	 		} 
 	 		

 

Here is the debug log

 

 

22:56:35.315|METHOD_EXIT|[85]|LeadExtensionController.queryString()
22:56:35.315|METHOD_EXIT|[165]|LeadExtensionController.getStEndorsements()
22:56:35.315|METHOD_ENTRY|[169]|System.debug(ANY)
22:56:35.315|USER_DEBUG|[169]|DEBUG|DEBUG ERROR = 'RAP','REX'
22:56:35.315|METHOD_EXIT|[169]|System.debug(ANY)
22:56:35.315|SOQL_EXECUTE_BEGIN|[171]|Aggregations:0|select Id, Name, BillingCity, Country_ISO_Code__c, Owner.Name, Type, Accreditations__c 
 	 				
					from Account where 	Type = 'Dealer' 
 	 				
 	 				AND Country_ISO_Code__c =: lead.Country_ISO__c
 	 				AND Accreditations__c includes (: endor ) 
 	 				AND Accreditations__c != null
 	 				
 	 				LIMIT 1000
22:56:35.357|SOQL_EXECUTE_END|[171]|Rows:0

 

 

The string I am passing in to the includes looks correct to me - can anyone spot what I am doing wrong.

 

Thanks

 

 

Sorry... what am I doing wrong here??

 

A simple trigger to get the record type name so I can run logic on it in workflow rules....

 

trigger ticketBefore on ticket__c (before insert, before update) {

	//Get the recods that triggered this event
    List<ticket__c> tkts = [
        select
        recordType.name,
        recordTypeName__c
        from ticket__c 
        WHERE id IN :Trigger.newMap.keySet()
    ];
    
	for (ticket__c t : tkts) {
	    t.recordTypeName__c = t.recordType.name;
	    system.debug('\n\nTHE RECORD TYPE ID IS: ' + t.recordTypeId);
	    system.debug('\n\nTHE TICKET RECORD TYPE ID IS: ' + t.recordTypeName__c);
	}
}

 

 

 

I don't see why this doesnt work... It's really frustrating...

 

 

 

 

 

DEBUG LOG returns results correct but it doesn't write to the field?!?

 

16.0 APEX_CODE,DEBUG;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;VALIDATION,INFO;WORKFLOW,INFO
11:47:05.587|EXECUTION_STARTED
11:47:05.587|CODE_UNIT_STARTED|[EXTERNAL]|TRIGGERS
11:47:05.587|CODE_UNIT_STARTED|[EXTERNAL]|01qA0000000ooan|ticketBefore on ticket trigger event BeforeUpdate for [a0XA0000001eHhf]
11:47:05.588|SOQL_EXECUTE_BEGIN|[4]|Aggregations:0|
select
recordType.name,
recordTypeName__c
from ticket__c
WHERE id IN :Trigger.newMap.keySet()

11:47:05.589|METHOD_ENTRY|[9]|MAP.keySet()
11:47:05.589|METHOD_EXIT|[9]|MAP.keySet()
11:47:05.596|SOQL_EXECUTE_END|[4]|Rows:1
11:47:05.596|METHOD_ENTRY|[15]|System.debug(ANY)
11:47:05.596|USER_DEBUG|[15]|DEBUG|

THE RECORD TYPE ID IS: 012A0000000pCocIAE
11:47:05.596|METHOD_EXIT|[15]|System.debug(ANY)
11:47:05.596|METHOD_ENTRY|[16]|System.debug(ANY)
11:47:05.596|USER_DEBUG|[16]|DEBUG|

THE TICKET RECORD TYPE ID IS: Logistics
11:47:05.596|METHOD_EXIT|[16]|System.debug(ANY)
11:47:05.596|CUMULATIVE_LIMIT_USAGE
11:47:05.596|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 1 out of 20
Number of query rows: 1 out of 1000
Number of SOSL queries: 0 out of 0
Number of DML statements: 0 out of 20
Number of DML rows: 0 out of 100
Number of script statements: 4 out of 10200
Maximum heap size: 0 out of 3000000
Number of callouts: 0 out of 10
Number of Email Invocations: 0 out of 10
Number of fields describes: 0 out of 100
Number of record type describes: 0 out of 100
Number of child relationships describes: 0 out of 100
Number of picklist describes: 0 out of 100
Number of future calls: 0 out of 10
Number of find similar calls: 0 out of 0
Number of System.runAs() invocations: 0 out of 20

11:47:05.596|CUMULATIVE_LIMIT_USAGE_END

11:47:05.597|CODE_UNIT_FINISHED|ticketBefore on ticket trigger event BeforeUpdate for [a0XA0000001eHhf]
11:47:05.605|CODE_UNIT_STARTED|[EXTERNAL]|Validation:ticket:a0XA0000001eHhf
11:47:05.605|VALIDATION_RULE|03dA0000000lFPK|TKT100
11:47:05.606|VALIDATION_FORMULA|subject__c = null|subject__c=BES Server problems
11:47:05.606|VALIDATION_PASS
11:47:05.606|CODE_UNIT_FINISHED|Validation:ticket:a0XA0000001eHhf
11:47:05.661|CODE_UNIT_FINISHED|TRIGGERS
11:47:05.662|EXECUTION_FINISHED
  • January 20, 2011
  • Like
  • 0

I have two questions around apex scheduler Jobs. Any help would be very useful

 

a) Why scheduled jobs that are in "COMPLETED" or "DELETED" state show up in Monitoring-->Scheduled Jobs and count towards the limit of 10 scheduled jobs. Any thoughts to get around this?

 

b) I am trying to delete jobs in CronTrigger table. I am getting the following error message the job still remains in the list of scheduled jobs. However, if i manually delete by going to Monitoring-->Scheduled Jobs in the org, it works. Any idea why I am getting the below exception? Suggestion to resolve this would be very useful.

 

java.sql.SQLException: ORA-20001:
ORA-06512: at "DOC.CMETAACCESS", line 542
ORA-01403: no data found
ORA-06512: at "DOC.CMETAACCESS", line 706
ORA-06512: at "DOC.CMETAACCESS", line 694
ORA-06512: at "DOC.CMETAACCESS", line 663
ORA-06512: at "DOC.CMETAACCESS", line 641
ORA-06512: at "DOC.UDDDMLCRONTRIGGER", line 65
ORA-06512: at line 1
: {call UddDmlCronTrigger.get_detail(?,?,?)}