New answers tagged

1 vote
Accepted

How to handle and get duplicate values after receiving the duplicate value error message

Database.DuplicateError is only for Duplicate Rules. Instead, you can check getStatusCode on the error and compare it with StatusCode.DUPLICATE_VALUE. However, that still won't tell you which record ...
  • 445k
0 votes

Can we add the debug statement without a method?

There are two kinds of executable blocks in Apex. There are static blocks and instance blocks. Static blocks can be anonymous blocks and static methods. Instance blocks come in two basic flavors: ...
  • 445k
0 votes

Can we add the debug statement without a method?

You should have at least constructor in your apex class to write the system.debug statement as below. public class sample1234 { integer h=10; public sample1234(){ system.debug(h); } } ...
1 vote

CPU Time limit exception inside trigger

Your code has a lot of logic bugs in it. resultMapMPAT should be a plain old Set, Trigger.new can't be used in an after delete trigger, you should never truncate 18-character ID values like that (it's ...
  • 445k
0 votes
Accepted

Insert or update campaign member after if condition

Let's rewrite this a bit List<CampaignMember> matchingCampaignMembers = [Select id,Status from CampaignMember where ContactId=:c.Id and CampaignId =:camp.Id]; ...
  • 63.8k
0 votes

Populate lookup field - Apex class

I have no idea if it makes sense. Probably you should replace [SELECT Id, Responsibility_Center__c, Account.RC__c FROM Case] with something more relevant. So. We go through cases. I assumed, that ...
  • 1,347

Top 50 recent answers are included