• kibitzer
  • NEWBIE
  • 327 Points
  • Member since 2010
  • CTO
  • Full Circle Insights


Badges

  • Chatter
    Feed
  • 11
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 12
    Questions
  • 120
    Replies
Please take a look at the screenshot and tell me what the Duration column unit of measure is in. I am trying to help answer this question (https://developer.salesforce.com/forums/#!/feedtype=SINGLE_QUESTION_DETAIL&dc=General_Development&criteria=ALLQUESTIONS&id=906F0000000MK4kIAG" target="_blank)so I am looking at the performance tree data for the guy.

Performance Tree Duration - Unit of measure doesn't seem consistent
Error: FATAL_ERROR|System.LimitException: Apex CPU time limit exceeded

The records basically come into my trigger code at Step 7 here (who knows if this is up to date):
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_order_of_execution.htm

And the CPU limit shows it is over the limit as soon as it hits my package.
Maximum CPU time: 13170 out of 10000 ******* CLOSE TO LIMIT

At this point as an App Builder what the heck can I do? The user doesn't seem to understand I can't controll all the workflows they have setup. Of course the error email they get is right when it comes into my package and tries to run the first line so it looks like I'm the cause and Salesforce Support just tells them the same thing so it is futile to argue. Even running a limit check to see if the limits are blown throws the exception
 
Upon checking the code coverage of our APEX Classes, we've noticed that a few of our actual Test Classes are evaluated as well. We found out that this is because of the non-test methods with parameters in our Test Classes. These methods are really just helper functions for the Test Classes, but it's frustating that they are the ones that cause the Test Classes to be evaluated in the overall code coverage numbers. (as described in https://help.salesforce.com/apex/HTViewSolution?urlname=Why-is-a-Test-class-evaluated-as-part-of-the-Organization-s-Code-Coverage&language=en_US (https://help.salesforce.com/apex/HTViewSolution?urlname=Why-is-a-Test-class-evaluated-as-part-of-the-Organization-s-Code-Coverage&language=en_US))

Is there any work around here? We also found out that the same pattern is actually used in the examples from the Force.com Apex Code Developer's Guide and the APEX Workbook. See https://developer.salesforce.com/docs/atlas.en-us.apex_workbook.meta/apex_workbook/apex_testing_1.htm and https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_testing_utility_classes.htm. Does this mean that we also have to create test classes for those test helper methods?

Thanks in advance,
Mishael

 
Hi,

I am suffering with Salesforce apex LimitException issue. I am fetching thousands of records from few objects and putting it into the collection like Map. Now I have a requirement to generate JSON for same records which will be used for mobile devices to download data from salesforce.
When I tried to serialize those records by using System.JSON.Serialize() method; it is generating a huge JSON string and I am getting System.LimitException error because there will be more memory required than available space.
I tried to catch that issue using try/catch block but here is a reference available which says that System.LimitException can’t be caught by Catch block.
Referral URL: http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_exception_methods.htm
I know that we can check heap size limit through Limits.getHeapSize() method. But is there any work around so that I can handle this issue from apex side.
A code sample or some reference in this regard would be highly appreciated.
Thanks in advanced.
I would like some help on a trigger and apex class i am working on. Below is the code.  It occurs when i try to submit the survey.

ERROR CODE:
System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, Trigger_SurveyAfterInsert: execution of AfterInsert caused by: System.QueryException: List has no rows for assignment to SObject Trigger.Trigger_SurveyAfterInsert: line 8, column 1: []
Error is in expression '{!insertSurvey}' in component <apex:commandButton> in page vf_sales_survey: Class.VFController_survey_opps.insertSurvey: line 44, column 1

Class.VFController_survey_opps.insertSurvey: line 44, column 1



TRIGGER:
trigger Trigger_SalesSurveyAfterInsert on Survey__c(after insert) {

   
     for(Survey__c event: System.Trigger.New){
        List<Survey__c> lobjects;
        string name;
        lobjects = [select Id, Opportunity__c, OppId__c from Survey__c where Id=:event.Id];
        if(lobjects.size() == 1){
            Survey__c srv = lobjects[0];
            Opportunity opp = [select Id, AccountId from Opportunity where Id=:srv.Opportunity__c  ];
            srv.Opportunity__c = opp.Id ;
            srv.Account__c = opp.AccountId ;
           
            update srv;
        }
    }


}


APEX CODE:
public with sharing class VFController_survey_opps {
public String oppId {get;set;}

        public Integer q1{get;set;}
        public Integer q2{get;set;}
        public Integer q3{get;set;}
        public Integer q4{get;set;}
        public Integer q5{get;set;}
        public Integer q6{get;set;}
        public Integer q7{get;set;}
        public Integer q8{get;set;}
        public Integer q9{get;set;}
        public Integer q10{get;set;}
        public Integer q11{get;set;}
        public Integer q12{get;set;}
        public Integer q13{get;set;}
        public Integer q14{get;set;}
        public String comments{get;set;}
       
        public VFController_survey_opps()
        {
                oppId = ApexPages.currentPage().getParameters().get('oppId');
        }
       
        public PageReference insertSurvey(){
                Survey__c sv = new Survey__c();
             
                sv.OppId__c = oppId;
                sv.Question_1__c = q1;
                sv.Question_2__c = q2;
                sv.Question_3__c = q3;
                sv.Question_4__c = q4;
                sv.Question_5__c = q5;
                sv.Question_6__c = q6;
                sv.Question_7__c = q7;
                sv.Question_8__c = q8;
                sv.Question_9__c = q9;
                sv.Question_10__c = q10;
                sv.Question_11__c = q11;
                sv.Question_12__c = q12;
                sv.Question_13__c = q13;
                sv.Question_14__c = q14;
                sv.Comments__c = comments;
                insert sv;
               
                //put a redirect to a new thank you vf page
               
                PageReference cPage = new PageReference('/apex/vr_survey_thank_you');
        cPage.setRedirect(true);
        return cPage;
       
                return null;
        }
       
         public List<SelectOption> getItems() {
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('5','Excellent'));
        options.add(new SelectOption('4','Good'));
        options.add(new SelectOption('3','Average'));
        options.add(new SelectOption('2','Fair'));
        options.add(new SelectOption('1','Poor'));
        options.add(new SelectOption('0','NA'));
       
       
        return options;
    }
   
    public List<SelectOption> getItems2() {
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('5','Excellent'));
        options.add(new SelectOption('4','Good'));
        options.add(new SelectOption('3','Average'));
        options.add(new SelectOption('2','Fair'));
        options.add(new SelectOption('1','Poor'));
        options.add(new SelectOption('0','NA'));
       
        return options;
    }

 
}
Hi

I am working with ternary operator , but it always giving false value

string resName';

resName =  (obj.order_number__c == 1) ?obj.Response : ' NA';

Here order number type is number
Response is Text
But above ternary expression always gives 'NA'.

I tried with native IF like

if(obj.order_number__c == 1)
     resName = obj.Response;
else
    resName = 'NA';

the above code is working fine, but it is not working by using ternary operator.
Anyone explain me the why it is not working.
We run several batch and scheduled jobs daily. Earlier I used to have two seperate classes - one that implements Database.Batchable and another class that implements the schedulable interface. Then I run the scheduled job from the Dev console.

I combined both the above classes into a single class that implements both the interfaces. The code compiled and has been running batch jobs daily.

But every once in a while the job gets aborted. However when I run the same job manually (i.e. go to the Dev console and run) it runs OK. Did any one else have the same issue.

I contacted Salesforce support and their feedback was that the SOQL query in the Start function is timing out. They opened up the SOQL timeout limits and the job continued working for some time (~90 days) and I now see the job aborting every once in a while.

Any one tried the same above and seen any issues.


Hello,

I have an Apex Trigger that excutes whenever a Product is (Inserted/Edited/Deleted) from OpportunityLineItem. The trigger needs to check a picklist value from a custom picklist in Opportunity Object. The code in the trigger will execute if there is matching value, else do nothing. I have the trigger written as follows. I'm not getting any error, the trigger excutes the desired code without checking the IF Condition.

Apex Trigger:

 trigger OppAmountTotal on OpportunityLineItem (after delete, after insert, after update, after undelete) {
    OpportunityLineItem oli = [Select OpportunityId from OpportunityLineItem LIMIT 1];
    Opportunity o = [SELECT CustomPicklist FROM Opportunity WHERE Id = :oli.OpportunityId];
    if(o.CustomPicklist == 'Yes - Add to Total'){
        if(trigger.isInsert || trigger.isUpdate || trigger.isUnDelete){
            list<TotalAmount.fieldDefinition> fieldDefinitions =
            new list<TotalAmount.fieldDefinition> {
                new TotalAmount.fieldDefinition('SUM', 'TotalPrice',
                'Amount')
            };
            TotalAmount.rollUpTrigger(fieldDefinitions, trigger.new,
            'OpportunityLineItem', 'OpportunityId', 'Opportunity', '');
        }
        if(trigger.isDelete){
            list<TotalAmount.fieldDefinition> fieldDefinitions =
            new list<TotalAmount.fieldDefinition> {
                new TotalAmount.fieldDefinition('SUM', 'TotalPrice',
                'Amount')
            };
            TotalAmount.rollUpTrigger(fieldDefinitions, trigger.old,
            'OpportunityLineItem', 'OpportunityId', 'Opportunity', '');
        }
    }
}
I need some help.  I created a batch process, that updates a group of records every morning.  Everything works fine in my sandbox but when I moved the code over to production and started running it, I get the following error:
Apex script unhandled exception by user/organization: ################/##################

Failed to process batch for class 'BatchUpdate_ServiceCenter_Enrollment' for job id '7075000000hItM9'

caused by: System.LimitException: Too many DML statements: 151

Class.BatchUpdate_ServiceCenter_Enrollment.execute: line 14, column

Here is the Batch Class
global class BatchUpdate_ServiceCenter_Enrollment implements Database.Batchable<sObject>
{
    global Database.QueryLocator start(Database.BatchableContext BC)
    {
        String query = 'SELECT Id,Auto_Update__c FROM Enrollment_Base__c ';
        return Database.getQueryLocator(query);
    }
 
    global void execute(Database.BatchableContext BC, List<Enrollment_Base__c> scope)
    {
        for (Enrollment_Base__c eb : scope){

         if(eb.Auto_Update__c == True)
          update eb;

        }
    }  

global void finish(Database.BatchableContext BC)
    {
   // Get the ID of the AsyncApexJob representing this batch job
    // from Database.BatchableContext.
    // Query the AsyncApexJob object to retrieve the current job's information.
    AsyncApexJob a = [Select Id, Status, NumberOfErrors, JobItemsProcessed,
                        TotalJobItems, CreatedBy.Email
                        from AsyncApexJob where Id = :BC.getJobId()];
    // Send an email to the Apex job's submitter notifying of job completion.
    Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
    String[] toAddresses = new String[] {a.CreatedBy.Email};
    mail.setToAddresses(toAddresses);
    mail.setSubject('Batch Apex Update Event ' + a.Status);
    mail.setPlainTextBody('The batch Apex job processed ' + a.TotalJobItems +
                            ' batches with '+ a.NumberOfErrors + ' failures.' );
    Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
    }

}
Here is the Update Class
public with sharing class Update_Enrollement {
/* 
  Developer     : Jim Jackson
  Created       : 08/12/2014
  Last Modified : 
  Test Class    : 
  Objective     : 
  
*/ 

    public void beforeUpdate(Enrollment_Base__c[] newlist){
        List<Date> dtStart =  new List<Date>();
        List<Date> dtEnd =  new List<Date>();
        String strKey;
        Double GMAmount = 0 ;
        Boolean strStatus ;
        String strName;

            for(Enrollment_Base__c EB : newList){
              dtStart.add(EB.Start_Date__c);    
              dtEnd.add(EB.End_Date__c);
              strKey = EB.Service_Center__c;   
              strStatus = EB.Auto_Update__c;
              strname = EB.id;
            }
                
                System.debug(strKey);
                System.debug(dtStart);
                System.debug(dtEnd);
                System.debug(strName);
           
    If(strstatus = true){
        List<aggregateResult> fpresults = [select Count(Id) Total from SD_Mbr_Enroll_Cycles__c 
                                             where Use_Me__c = True
                                             And Enrollment_Status__c = 'Enrolled'
                                             And Enrollment_Status_Date__c >= :dtStart
                                             And Enrollment_Status_Date__c <= :dtEnd
                                             And Service_Center_Id__c = :strKey.SubString(0,15)];           
        for (AggregateResult ar : fpresults )  {
            GMAmount = (Double)ar.get('Total');
                }
            
        for(Enrollment_Base__c GM : newList){
            GM.Enrolled__c =  GMamount;
            GM.id = strname; 
                }   


    }
    }
}

Here is the Trigger
trigger EnrollmentUpdating on Enrollment_Base__c (after delete, after insert, after undelete, 
after update, before delete, before insert, before update) {


if(trigger.isUpdate && trigger.isBefore){
            Update_Enrollement Handler = new Update_Enrollement();
            handler.beforeUpdate(Trigger.new); 
    }  
}

Any Ideas?
20.0 APEX_CODE,DEBUG;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;SYSTEM,DEBUG;VALIDATION,INFO;VISUALFORCE,INFO;WORKFLOW,INFO
12:01:10.119 (119157280)|EXECUTION_STARTED
12:01:10.119 (119200824)|CODE_UNIT_STARTED|[EXTERNAL]|01pE000000000a1|TerritoryAlignment
12:01:10.161 (161388605)|METHOD_ENTRY|[5]|01pE000000000a1|TerritoryAlignment.TerritoryAlignment()
12:01:10.161 (161466583)|METHOD_EXIT|[5]|TerritoryAlignment
12:01:10.182 (182010006)|METHOD_ENTRY|[8]|01pA0000001oPla|BatchJobUtils.BatchJobUtils()
12:01:10.182 (182084454)|SYSTEM_CONSTRUCTOR_ENTRY|[30]|<init>(Integer)
12:01:10.182 (182137857)|SYSTEM_CONSTRUCTOR_EXIT|[30]|<init>(Integer)
12:01:10.182 (182176141)|SYSTEM_METHOD_ENTRY|[30]|SET<String>.add(Object)
12:01:10.182 (182194798)|SYSTEM_METHOD_EXIT|[30]|SET<String>.add(Object)
12:01:10.182 (182208546)|SYSTEM_METHOD_ENTRY|[30]|SET<String>.add(Object)
12:01:10.182 (182219542)|SYSTEM_METHOD_EXIT|[30]|SET<String>.add(Object)
12:01:10.182 (182231733)|SYSTEM_METHOD_ENTRY|[30]|SET<String>.add(Object)
12:01:10.182 (182242334)|SYSTEM_METHOD_EXIT|[30]|SET<String>.add(Object)
12:01:10.182 (182254105)|SYSTEM_METHOD_ENTRY|[30]|SET<String>.add(Object)
12:01:10.182 (182264782)|SYSTEM_METHOD_EXIT|[30]|SET<String>.add(Object)
12:01:10.182 (182276570)|SYSTEM_METHOD_ENTRY|[30]|SET<String>.add(Object)
12:01:10.182 (182287244)|SYSTEM_METHOD_EXIT|[30]|SET<String>.add(Object)
12:01:10.182 (182299032)|SYSTEM_METHOD_ENTRY|[30]|SET<String>.add(Object)
12:01:10.182 (182309704)|SYSTEM_METHOD_EXIT|[30]|SET<String>.add(Object)
12:01:10.182 (182321427)|SYSTEM_METHOD_ENTRY|[30]|SET<String>.add(Object)
12:01:10.182 (182336971)|SYSTEM_METHOD_EXIT|[30]|SET<String>.add(Object)
12:01:10.182 (182349212)|SYSTEM_METHOD_ENTRY|[30]|SET<String>.add(Object)
12:01:10.182 (182359748)|SYSTEM_METHOD_EXIT|[30]|SET<String>.add(Object)
12:01:10.182 (182371449)|SYSTEM_METHOD_ENTRY|[30]|SET<String>.add(Object)
12:01:10.182 (182382116)|SYSTEM_METHOD_EXIT|[30]|SET<String>.add(Object)
12:01:10.182 (182393862)|SYSTEM_METHOD_ENTRY|[30]|SET<String>.add(Object)
12:01:10.182 (182404537)|SYSTEM_METHOD_EXIT|[30]|SET<String>.add(Object)
12:01:10.182 (182429131)|METHOD_EXIT|[8]|BatchJobUtils
12:01:10.183 (183647973)|METHOD_ENTRY|[81]|01pA0000001oPla|BatchJobUtils.setRunning(Id)
12:01:10.185 (185580043)|SOQL_EXECUTE_BEGIN|[120]|Aggregations:0|select Id from Batch_Job__c where Id = :tmpVar1
12:01:10.188 (188411566)|SOQL_EXECUTE_END|[120]|Rows:1
12:01:10.188 (188550692)|SYSTEM_METHOD_ENTRY|[121]|LIST<Batch_Job__c>.isEmpty()
12:01:10.188 (188577929)|SYSTEM_METHOD_EXIT|[121]|LIST<Batch_Job__c>.isEmpty()
12:01:10.188 (188598904)|SYSTEM_METHOD_ENTRY|[122]|LIST<Batch_Job__c>.get(Integer)
12:01:10.188 (188646639)|SYSTEM_METHOD_EXIT|[122]|LIST<Batch_Job__c>.get(Integer)
12:01:10.188 (188740846)|DML_BEGIN|[124]|Op:Update|Type:Batch_Job__c|Rows:1
12:01:10.261 (261542811)|DML_END|[124]
12:01:10.261 (261592724)|METHOD_EXIT|[81]|01pA0000001oPla|BatchJobUtils.setRunning(Id)
12:01:10.261 (261659324)|SYSTEM_METHOD_ENTRY|[83]|System.debug(ANY)
12:01:10.261 (261692205)|USER_DEBUG|[83]|DEBUG|Query : SELECT Id, Customer__c, Territory_Custom__c,  Territory_Custom__r.Name, Territory_Custom__r.Territory_Id__c,  Territory_Custom__r.Group_Id__c,  Account_Share_Id__c, Is_Marked_for_Delete__c  FROM Account_Territory__c  WHERE Account_Share_Id__c = NULL and Is_Marked_for_Delete__c = FALSE  LIMIT 1000000
12:01:10.261 (261701167)|SYSTEM_METHOD_EXIT|[83]|System.debug(ANY)
12:01:10.272 (272605280)|METHOD_ENTRY|[12]|01pA0000001oPmU|CodeSettingUtils.CodeSettingUtils()
12:01:10.272 (272702512)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.272 (272753205)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.272 (272778685)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.272 (272794337)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.272 (272812314)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.272 (272826579)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.272 (272844713)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.272 (272858708)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.272 (272876043)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.272 (272889717)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.272 (272905891)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.272 (272919455)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.272 (272938113)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.272 (272951908)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.272 (272969423)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.272 (272983080)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273000441)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273015886)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273032566)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273046930)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273061714)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273075370)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273091822)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273105418)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273121497)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273135824)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273153465)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273167335)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273184698)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273198534)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273215033)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273229240)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273246458)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273260371)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273277037)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273290708)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273313062)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273327845)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273345652)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273359332)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273376709)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273390353)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273410616)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273425681)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273443366)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273457066)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273474137)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273487842)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273510383)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273526564)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273544474)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273558346)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273575787)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273589674)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273620909)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273635533)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273652403)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273666294)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273683891)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273697875)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273713313)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273726754)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273743582)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273757228)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273773558)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273787398)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273805115)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273818970)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273835793)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273849572)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273866608)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273880469)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273895803)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273909396)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273929531)|SYSTEM_METHOD_ENTRY|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273943837)|SYSTEM_METHOD_EXIT|[71]|MAP<String,String>.put(Object, Object)
12:01:10.273 (273970773)|METHOD_EXIT|[12]|CodeSettingUtils
12:01:10.275 (275575812)|METHOD_ENTRY|[85]|01pA0000001oPmU|CodeSettingUtils.getTargetID(String)
12:01:10.275 (275808916)|SYSTEM_METHOD_ENTRY|[223]|CommonSettings__c.getInstance(String)
12:01:10.277 (277516687)|SYSTEM_METHOD_EXIT|[223]|CommonSettings__c.getInstance(String)
12:01:10.277 (277580360)|SYSTEM_CONSTRUCTOR_ENTRY|[224]|<init>()
12:01:10.277 (277612047)|SYSTEM_CONSTRUCTOR_EXIT|[224]|<init>()
12:01:10.277 (277621769)|SYSTEM_CONSTRUCTOR_ENTRY|[225]|<init>()
12:01:10.277 (277634537)|SYSTEM_CONSTRUCTOR_EXIT|[225]|<init>()
12:01:10.277 (277672936)|SYSTEM_METHOD_ENTRY|[227]|String.split(String)
12:01:10.277 (277717624)|SYSTEM_METHOD_EXIT|[227]|String.split(String)
12:01:10.280 (280341599)|SOQL_EXECUTE_BEGIN|[229]|Aggregations:0|select Id from User where username IN :tmpVar1
12:01:10.285 (285461038)|SOQL_EXECUTE_END|[229]|Rows:0
12:01:10.285 (285638711)|SYSTEM_METHOD_ENTRY|[230]|LIST<User>.size()
12:01:10.285 (285667057)|SYSTEM_METHOD_EXIT|[230]|LIST<User>.size()
12:01:10.285 (285686223)|METHOD_EXIT|[85]|01pA0000001oPmU|CodeSettingUtils.getTargetID(String)
12:01:10.285 (285726722)|SYSTEM_METHOD_ENTRY|[85]|com.salesforce.api.interop.apex.bcl.DatetimeMethods.now()
12:01:10.285 (285749377)|SYSTEM_METHOD_EXIT|[85]|com.salesforce.api.interop.apex.bcl.DatetimeMethods.now()
12:01:10.285 (285773459)|SYSTEM_METHOD_ENTRY|[85]|String.valueOf(Object)
12:01:10.285 (285795208)|SYSTEM_METHOD_EXIT|[85]|String.valueOf(Object)
12:01:10.294 (294655813)|METHOD_ENTRY|[14]|01pA0000001oPmk|EmailUtils.EmailUtils()
12:01:10.294 (294682503)|METHOD_EXIT|[14]|EmailUtils
12:01:10.296 (296055727)|METHOD_ENTRY|[85]|01pA0000001oPmk|EmailUtils.sendEmail(LIST<String>, String, String, Boolean, LIST<Messaging.EmailFileAttachment>, Boolean)
12:01:10.296 (296089329)|SYSTEM_METHOD_ENTRY|[48]|LIST<String>.size()
12:01:10.296 (296134515)|SYSTEM_METHOD_EXIT|[48]|LIST<String>.size()
12:01:10.296 (296149751)|METHOD_EXIT|[85]|01pA0000001oPmk|EmailUtils.sendEmail(LIST<String>, String, String, Boolean, LIST<Messaging.EmailFileAttachment>, Boolean)
12:01:10.296 (296177294)|SYSTEM_METHOD_ENTRY|[90]|Database.getQueryLocator(String)
12:01:10.302 (302054710)|SOQL_EXECUTE_BEGIN|[90]|Aggregations:0|SELECT Id, Customer__c, Territory_Custom__c,  Territory_Custom__r.Name, Territory_Custom__r.Territory_Id__c,  Territory_Custom__r.Group_Id__c,  Account_Share_Id__c, Is_Marked_for_Delete__c  FROM Account_Territory__c 
12:31:17.661 (1807661545838)|EXCEPTION_THROWN|[90]|System.UnexpectedException: Internal Salesforce.com Query Error
12:31:17.661 (1807661671103)|SYSTEM_METHOD_EXIT|[90]|Database.getQueryLocator(String)
12:31:17.661 (1807661743998)|FATAL_ERROR|System.UnexpectedException: Internal Salesforce.com Query Error

Class.TerritoryAlignment.start: line 90, column 1
12:31:17.952 (1807661876825)|CUMULATIVE_LIMIT_USAGE
12:31:17.952|LIMIT_USAGE_FOR_NS|(default)|
  Number of SOQL queries: 0 out of 200
  Number of query rows: 0 out of 50000
  Number of SOSL queries: 0 out of 20
  Number of DML statements: 0 out of 150
  Number of DML rows: 0 out of 10000
  Maximum CPU time: 0 out of 60000
  Maximum heap size: 0 out of 12000000
  Number of callouts: 0 out of 0
  Number of Email Invocations: 0 out of 10
  Number of future calls: 0 out of 0
  Number of Mobile Apex push calls: 0 out of 10

12:31:17.952|CUMULATIVE_LIMIT_USAGE_END

12:31:17.661 (1807661912023)|CODE_UNIT_FINISHED|TerritoryAlignment

Hi Guys,

I am trying to merge two contacts. Class is using the keyword  "without sharing". So the the class is running in system admin mode. I have checked the system admin profie, the profile is having all permissions(DELETE contact, MODIFY ALL DATA on contact).

I am calling this class on another class , that parent class is also using the keyword "without sharing". But still I am getting below error:
Merge failed. First exception on row 0 with id 0031100000XXYfRAAX; first error: INSUFFICIENT_ACCESS_OR_READONLY, cannot merge with entity that is not accessible: []

Below is class code:

public without sharing class DeleteContact {
    public void deleteContact(String contactId,string email){
        Map<String, Schema.SobjectField> contactfields = Schema.SObjectType.contact.fields.getMap();
        List<Schema.SObjectField> fldObjMapValues = contactfields.values();
        string theQuery1;
        string theQuery2;
        String theQuery = 'SELECT ';
            for(Schema.SObjectField s : fldObjMapValues)
            {
               String theLabel = s.getDescribe().getLabel();
               String theName = s.getDescribe().getName();
               theQuery += theName + ',';
            }
            theQuery = theQuery.subString(0, theQuery.length() - 1);
          
            theQuery1 = theQuery + ' FROM Contact WHERE Id =: contactId';
            theQuery2 = theQuery + ' FROM Contact WHERE Id !=: contactId AND Email =: email';
          
      
        Contact previouscontact=Database.query(theQuery1);
        List<Contact> listContacts=Database.query(theQuery2);
        if(previouscontact!=null && listContacts[0]!=null){
            try{
                merge  previouscontact listContacts[0];
            }
            catch(Exception e){
                system.debug('============='+e.getMessage());
            }
    }
}


Can some one please suggest me why this error is coming?. Urgent Please.
Hello, I have recently been working with a new Brazilian employee that was having difficulty entereing a opportunity (language was set as Portugese). After doing some research it seems that the user was causing an error in a trigger we have on insert and update for Opportunities (see below)

List<string> AdminProfileNames = 'System Administrator'.split(',');
List<Profile>Admin_Profiles = [Select Id, Name from Profile where Profile.name in :AdminProfileNames];
system.debug('Admin_Profiles[0].id='+Admin_Profiles[0].id);

System.ListException: List index out of bounds: 0

After looking into the code I changed it to the code below and it worked fine for this user.

 List<string> AdminProfileNames = 'System Administrator,Administrador do sistema'.split(',');
List<Profile>Admin_Profiles = [Select Id, Name from Profile where Profile.name in :AdminProfileNames];
system.debug('Admin_Profiles[0].id='+Admin_Profiles[0].id);

This brings up a larger question for me. Through all of my years of programming I have been told that matching things on straight text is dangerous and to use IDs whenver possible. In Salesforce, however, this seems to be used in criteria for searches, rules, exceptions, etc.and is almost the preffered way of doign things. So as our company moves more into international markets I have been told that Translation Workbench is the way to go for multi-Lingual support. I don't know much about this product, but I wanted to see if this will solve all our problems in all the areas of concern (inside APEX triggers, criteria for rules, etc.) or if there are any large problems that still have not been solved with this option.  
Hello,

Although this is available in the UI, is the field name not available for use in a SOQL statement yet, or am I just missing something simple? 

Here's what I'm trying in the workbench without any luck:
SELECT ContractId FROM Opportunity

Thank you,
Brian
Hello all -

I am trying to merge two accounts. Both the accounts, I am using a describe call to get all the fields. In my scenario I am checking if the master account has blank values in any of the fields, I am filling it with the losing account values. However when I merge (Database.merge(masteraccount,loseraccount), I get this error:

salesforce MERGE_FAILED, Invalid field IsPartner for merge: []

I checked few forums, but hardly got anything online.

Can anyone throw some light?

Regards,
Priyanka.