• 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
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

 

I got this error  when  I including TestMethod with in the apex class like this...

 

 

public class nsorcon {
    public nsorcon(ApexPages.StandardSetController controller) {

    }

     private  list<contact> conlist;
     id uid=userinfo.getuserid();
     user u=[select id,contactid from user where id=:uid];  
     public list<contact> getcontacts(){
          
           conlist=[select ....................];
         return conlist;
    }
  @istest
  static testmethod void testmehod1(){ 
  PageReference pg = Page.mysponsors; 
  Test.setCurrentPage(pg);
  
   contact[] cc=new contact[]{
   new contact(lastname='sample'),new contact(lastname='sample1')};
       
    ApexPages.StandardsetController strcontroller = new ApexPages.StandardsetController(cc);
     
   nsorcon qcc = new nsorcon(strcontroller);
    qcc.getcontacts();
    
   }
  
}

 If I remove @istest in apex class No error. Should I use apex TestMethod in apex class directly or any other  restrictions ...

I'm trying to delete a custom object via the SOAP API.  All I can find is info on deleting the records in the object, but not the object itself.  I'd like to permanently delete the object as well.  I tried the delete method (http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_delete.htm) but this seems to be for deleting records; when I make the call I get the error "MALFORMED_ID". I'm passing in the custom object name (ending in __c), but when I describe the object I don't see an id associated with the object.  I can also confirm that "deletable" is true for this object.  Can someone point me in the right direction?

 

Thanks,

Tim

OK I'm pulling my hair out. I'm trying to access a field from the account object after a contact is inserted. Here's the generic code:

 

trigger contactTest on Contact(after Insert)
{
 //Create list and set
 List<Contact> listContact = new List<Contact>();
 Set<Id> setContact = new Set<Id>();

 //Loop through trigger items
 For(Contact loopContact : Trigger.new)
 {
  //Create new contact for updating
  Contact newContact = new Contact(Id = loopContact.Id);

  //Get field from Account
  newContact.FieldFromAccount = loopContact.Account.FieldFromAccount;
  
  //Make sure distinct list of contacts
  if(!(setContact.contains(loopContact.Id))
  {
   listContact.add(newContact);
   setContact.add(newContact.Id);
  }
 }

 //Update list of Contacts
 update listContact;
}

 

The field comes up as null even though it's populated. It's a checkbox. What am I doing wrong?

I'm getting a null pointer exception on a simple if check of a boolean variable. Here is the simplified version of the code that generates the exception: 

Boolean boolVar = false; 
if ( boolVar ) 
doSomething(); 

If I modify that and change "if ( boolVar )" to "if ( boolVar == true )" the null pointer exception goes away.  This appears to be a bug in apex code. I can't reproduce this outside of my developer org or even with a simplified example in that org though.  Here are one of the error messages I'm receiving: 

----------------------------- 
System.DmlException: Update failed. First exception on row 0 with id a078000000KSAKhAAP; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, CRMfusionDBR101.DB_Scenario_Key_BIU: execution of BeforeUpdate 

caused by: System.NullPointerException: Attempt to de-reference a null object 

Class.CRMfusionDBR101.DB_Scenario.ProcessScenarioLinkUpdates: line 1405, column 1 
Trigger.CRMfusionDBR101.DB_Scenario_Key_BIU: line 17, column 1: [] 
------------------------- 

The line of code this points to is a line that just contains "else", nothing else. 

However, if I change line 1507 in that file from: 

if ( rowChanged ) 

to: 

if ( rowChanged == true ) 

This error, and several others in my unit tests (some pointing to different lines) disappears. I can change back and forth to reproduce that issue. As far as apex code is concerned, both of those statements should be evaluated exactly the same. Even if the rowChanged variable was null it would still evaluate to false in an if check, not generate an exception. 

 

Other exceptions in the unit tests, caused by this (again, all disappear with the simple change above):

 

caused by: System.NullPointerException: Attempt to de-reference a null object

Class.CRMfusionDBR101.DB_Scenario.ProcessScenarioLinkUpdates: line 1405, column 1

 

caused by: System.ListException: List index out of bounds: 1

Class.CRMfusionDBR101.DB_Scenario.ProcessScenarioLinkUpdates: line 1559, column 1

 

System.ListException: List index out of bounds: 1

 

Stack Trace

Class.CRMfusionDBR101.DB_Scenario.updateScenarioLinks: line 1327, column 1

   

 

caused by: System.StringException: Invalid regex: Unclosed group near index 4
(\A

^

Class.CRMfusionDBR101.DB_Scenario.ProcessScenarioLinkUpdates: line 1452, column 1

 

caused by: System.NullPointerException: Attempt to de-reference a null object

Class.CRMfusionDBR101.DB_BuildKeyUpdates.buildKeyUpdates: line 342, column 1

 

Thanks,

  • August 22, 2012
  • Like
  • 0

Hello

My organization has our own custom Lead Assignment Rules but they aren't firing whenever a Lead comes in from an external source. I've come to find out that the following code has to be executed as detailed here: http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_database_dmloptions.htm

Unfortunately, there realy isn't a controller or class that inserts Leads, which is where the code detailed above would be inserted at. Instead, we are using a third party vendor that has set up web pages which then push the form information and create a Lead.

The closest thing I have is a before insert trigger with the following code:

if(Trigger.isInsert){
        Database.DMLOptions dmo = new Database.DMLOptions();
	dmo.assignmentRuleHeader.assignmentRuleId= '01Q60000000JZmdEAG';
			
	for(Lead l : Trigger.new){
		l.setOptions(dmo);
	}
}

 
This doesn't appear to be working though. Whenever Leads come in, they don't trigger the rules. Any help would be greatly appreciated.

I am very new to Apex so please forgive me if this is a stupid question. 

I have 2 custom salesforce objects.  s1 and s2.  s2 has a field that is unique to both it and s1.  It is called identifier.  I am creating a trigger that will update the fields on s2 when s1 is updated.  What I cannot figure out how to do is inside the trigger apex to find the id of s2 based on the identifier field of s1. 

Thanks

Hello,

A Newbie question I'm sure, but...

 

What is the proper method to define and insert a Queue via an Apex Trigger or Test Class?

I'm good with standard & custom sObjects and the like, but I've not been able to find any clear documentation for inserting queues.

 

I found the metadata reference, but I'm not sure it applies to Apex:

 

When I use a statement like this:

 

Queue myQueue = new queue(email=queEmail,name=queName,fullName=queFullName,queueSobject=Case);

  

I get this error:

 

Error: Compile Error: Entity 'Queue' not accessible in version 25.0 at line 2 column 8

 

this is line 2

 

public class caseUpdateShadowUser_Test

  

So, can someone tell me what I've missed, or simply provide or direct me to a clear explanation of how to define and insert a Queue via a Trigger or Test Class?

 

Thanks,

 

Jaimie

 

 

I am new to Apex Coding. Besides an unmanaged Clone List App and many Managed Apps , my Salesforce Org does not have any custom Apex Code in it.

 

I tried to Deploy an Apex Class to production and got the error on a test class, Failure Message: "System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, </BR></BR></BR><font color="blue">Redirecting in just a second.</font></BR><SCRIPT LANGUAGE="JavaScript">window.location = "../apex/SFSSDupeCatcher__SFSSDupeCatcher?dId0=MDAxRjAwMDAwMG5TWHg4SUFH&scId=YT...

 

I know how to fix this error (change validation rules on my Dupe Catcher App Temporarily.

 

This "quick fix" works for deploying my code, but what about when my Apex Code stays in production.

 

If new validation rules, either from DupeCatcher or for Contacts, Accounts etc are put into place after my code in deployed in production , this will break my test data. What are the implications of test data/classes/methods breaking in production? I know I won't be able to deploy new code, but is there anything else that happens, particulary to the code that the test method/class/data was written for? Will test methods that are broken break the classes they cover?

 

If you were just begining Apex Development in your organization, what would you do differently? How can Apex Code break in production? How can I prevent this?

 

Thanks,

 

Angelika

 

 

 

I like to write a util method for field describe, with can describe on given "Object", "Field",  But current apex feature doesn't seems to allow it, 

 

//this one will allow some flexibility in changing field names as per requirement. 

Sobject sobj = new Opportunity();

Schema.DescribeFieldResult f = sobj.get('Status').getDescribe(); 

 

//currently we can do this, but not useful much,

  Schema.DescribeFieldResult f = Opportunity.Status.getDescribe();  

 

 

Thanks

Ram

 

  • April 18, 2012
  • Like
  • 0

My Leads have a validation rule such that once someone views a Lead, they can't leave the status as "Open" (as in if the Status is "Open" and the Creation DateTime is not the current date time, then trigger an error message).

 

Now, we are using the Web-to-Lead to pump questions from the website into SFDC directly. The Web-to-Lead basically writes the contact information and their query into Leads (queries are written to a non visible field called " QA"). I wrote  a trigger executing on "After insert" such that a Task will be created, the QA from Lead will be copied into the Comments in the Task and then the QA field will be cleared.

 

My problem starts here. The validation rule doesn't allow me to save the "QA" as blank because the status is Open. Is there a way to bypass this validation rule just for this scenario? Or is there a better way?

 

Any comments will be appreciated. 

I could post all the usual HR buzzwords here, but being on the tech side I can get away without doing that. Besides, who reads those things? Have you ever seen someone post a job description that does not describe the company as the best place to work, the perfect team, and as close to utopia as can exist on earth (if you're just the right candidate)?

So what can I tell you? Obviously, we're crazy enough to let a tech guy post a job listing (though who knows if they'll ever let me do it again). I can also tell you that you'll be working with some really advanced products on the platform - and I'd argue that it's a lot more fun to support customer deployments of a product than ordinary consulting work, or being limited to just one org.

Here's the deal. This really is a great opportunity. You'll learn a lot. If you're good, you'll become great - a rock star. If you're a rock star already... well, at least you won't be bored :-)

Check it out: http://fullcirclecrm.com/now-hiring-business-analystsenior-business-analyst/

Two of my sandboxes upgraded today to Spring 13, and I can't Deploy metadata to them using the Force.com IDE. I'm seeing the errors:

 

   Problem: Unknown type name 'MobileSettings' specified in package.xml
   Problem: Unknown type name 'SecuritySettings' specified in package.xml

Has anyone seen this or know of a workaround?

 

Dan

 

Currently Winter 13 ClickJack protection prevents use of VisualForce pages on page layouts. Is this a bug or a change?

Steps to reproduce (Winter 13 sandbox):

Create the following VisualForce page:

<apex:page StandardController="Lead">

<!-- Begin Default Content REMOVE THIS -->
<h1>Congratulations</h1>
This is your new Page
<!-- End Default Content REMOVE THIS -->
</apex:page>

Add it to a lead page layout.

Now go to Enable Setup-Security Controls – Session Settings and select Enable clickjack protection for non-setup customer Visualforce pages

When you view a lead, you'll see an error:

"URL No Longer Exists". You have attempted to reach a URL that no longer exists on salesforce.com

I read the info in the release notes  - does this really mean that enabling this protection prevents all use of VisualForce pages on a page layout? That would be a huge breaking change for which there is no workaround.

Has anyone been able to deploy code from a dev org to a Winter 13 sandbox succesfully?

 

I'm getting timeout errors after just a few seconds.

I've had no luck overriding the default log levels (trying to set Workflows and Validation rules to None or Error), either on the test class filter settings, the debug monitoring, or the developer console. In each case, I'm either seeing the override having no effect, or I'm getting the dreaded

An internal server error has occurred


Just wondering if others are seeing this, or if I just got lucky?

 

It looks like the latest version of the IDE is broken for Dashboards -

1. It won't add dashboards using add/remove components

2. If you add them manually by editing package.xml, you can read the Dashboard xml by refreshing from the server, but you can't edit, or save changes or deploy. If you look at the force.com properties for the dashboards, it shows them as type Unknown, belonging to a package named Dashboards.

 

I'm pretty sure this worked on earlier versions of the IDE, but I'm not sure if the latest (24) was the one that broke it.

 

Has anyone seen this, or have any suggestions?

Here's a fun one that I"m hoping someone may have some insight on...

 

Apex Test Execution in Spring runs a bunch of tests at once (as compared to winter when it only ran 3 or 4 at a time).  I already logged a case to address a problem of sporadic limit exceptions occuring during Apex Test Execution.

 

Well, today I noticed that while running tests under Apex Test Execution, many of our VisualForce pages start returning:

 

"To protect all customers from excessive usage and Denial of Service attacks, we limit the number of long-running requests that are processed at the same time by an organization. Your request has been denied because this limit has been exceeded by your organization. Please try your request again later. "

 

It looks like SFDC isn't excluding those tests from whatever limits it uses to detect a DOS attack.

 

Has anyone seen this?

 

Our application has about 130 unit tests in 25 classes - some include bulk testing and complex scenarios - so they can take a while to run even individually.

 

Dan

One of the changes I've noticed with Spring is that Apex test execution now tries to run all selected tests as well instead of queuing most of them and actually running about two at a time. As a result (I believe), I find that I'm getting a lot of "Request Limit Exceeded" failures.  They seem to be fairly sporadic and common - and all of the tests pass without problem when run standalone (the problem only occurs when using Apex test execution, and does not occur on Winter 12).

 

We have about 130 unit tests in about 30 classes - and many of the tests are complex and time consuming (bulk-tests, etc).

 

Has anyone else experienced this? Is it a known issue?

 

Here's some code that works on a winter 12 dev org bug fails on a Spring 12 sandbox:

 

VisualForce controller:

 

public class Spring12Bug
{
    private Map<String, String> m_entries;

    public Map<String, String> Entries {
        get
        {
            if(m_entries==null) 
                m_entries = new Map<String, String>{'A'=>'Red','B'=>'Green','C'=>'Blue'};
            return m_entries;
        } 
    }

    public Set<String> getKeys()
    {
        return Entries.keyset();
    }


}

 

VisualForce page markup:

 

<apex:page controller="Spring12Bug" >
  <h1>Demonstration of bug</h1>
  <apex:dataTable var="thekey" value="{!Keys}">
      <apex:column headerValue="Entries" value="{!Entries[thekey]}" />
  </apex:dataTable>
</apex:page>

 

On Winter 12 you get:

 

Demonstration of bugEntries

Red
Green
Blue

 

 

On Spring preview you get:

 

Visualforce Error


Map key null not found in map.


(Color changed for readability).

 

There is a workaround - to put the lookup in an OutputText tag inside of the column instead of using the Value attribute. But I figure someone should know about this bug as well.

Has anyone run into this one....

 

On a Lead After Update trigger....

 

When a conversion has just occurred (new lead IsConverted is True, old lead IsConverted is false).....

 

No opportunity is being created....

 

The user sets the Conversion status (which maps to lead status) to any value....

 

The lead status is NOT set to the conversion lead status when you examine the lead.status in the Trigger.New collection.

 

However, if you query the same lead object during the trigger, the lead status HAS been updated to the conversion status.

 

Is this a feature? (and if so, why?)

Is it a bug?

 

Thoughts?

 

Ok, this one is perplexing and I'm hoping someone has some ideas....

 

I'm using an After Update trigger on Lead to check for lead conversion. At that point I want to look at the lead status. I was expecting the lead status to match the "conversion status" specified on the lead conversion page by the user. But at that point it in time (during the after update trigger) it still contains the original status value.

 

There is no other trigger being raised on the lead (that I can see in the debug logs) - yet when I do a report later on converted leads, the lead status does match the one specified on the lead conversion page.

 

So this leads me to wonder:

1. Is the lead status field actually being updated?

2. If so, when is it being updated, and what can I trigger on to look at it?

 

Any ideas?

Ok - here's something that still works on a Summer 10 developer system, but isn't working today on a Winter 11 sandbox. I'm pretty sure it worked last week.


Steps to recreate/reproduce:
Create custom field named Test on the CampaignMember object. Data type string, any length.

Create an apex page to edit CampaignMember object (see VB code below). Any attempt to save this page will cause error:
Error: j_id0:cmform:j_id1:j_id5:j_id6: An error occurred when processing your submitted information.

Sample Apex page to reproduce:

<apex:page StandardController="CampaignMember" >
<apex:form id="cmform" >
<apex:pageBlock title="Campaign Member Edit" mode="edit">
<apex:pageBlockButtons >
<apex:commandButton action="{!save}" value="Save"/>
<apex:commandButton action="{!cancel}" value="Cancel"/>
</apex:pageBlockButtons>
<apex:pageblockSection columns="2" >
<apex:inputField rendered="true" value="{!CampaignMember.Test__c }"/>
</apex:pageblockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

 

I'm pretty sure there are no security issues here - everything to repro was done under a system admin account. I've done a lot of experimenting with different fields - some standard fields cause the error, some don't.

 

So this leaves us with:

1. Any suggestions?

2. I would love to hear if anyone else can reproduce this on a Winter 11 instance.

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
  • January 06, 2016
  • Like
  • 0
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;
    }

 
}
  • August 20, 2014
  • Like
  • 0
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.
  • August 20, 2014
  • Like
  • 0
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.


  • August 20, 2014
  • Like
  • 0
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.