Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 2602

Questions relating to Apex, the native programming language for the Force.com platform. Use it for general questions on syntax, errors, constructs, and rules of use. Most questions should include a code *excerpt* to help answerers understand specifically what has gone wrong or why you need help.

1 vote

Unable to update a lookup field despite appearing in the debug log

The reason is that you are trying to implicitly update a field in a record that is NOT in the trigger context (i.e. liList) List<Line_Item__c> liLst = [SELECT Id,Name,Category__c,Product__c FROM Line …
cropredy's user avatar
  • 73.2k
2 votes

Trigger On Order to get Opportunity Line Item from opportunity to add in orderlineitem11

The reason you are getting duplicates is because when you insert the OrderItem (on after insert), this causes an OOTB roll up summary (on Order.TotalAmount) to execute on parent Order that then causes …
cropredy's user avatar
  • 73.2k
5 votes
Accepted

SOQL limit exceeds for tracking cases

OK, the reason you are exceeding the SOQL limit is because you are querying for Profile over and over again within the for (CaseComment ...) loop, the for (EmailMessage ...) loop and the for (CaseHist …
cropredy's user avatar
  • 73.2k
14 votes
1 answer
7k views

ApexPages.addMessage() behavior inconsistent by version

While converting a utility class from V26 to V31, my VF testmethods started breaking. Problem was traced down to how ApexPages.addMessage() behavior varies if the i+1st message has the same summary a …
cropredy's user avatar
  • 73.2k
1 vote

Opportunity.IsWon isn't won in test context

You can create Opportunity objects with isWon set to true without having to go through DML to set the stageName to something that maps to 'won' as defined by the point-and-click set up. Here's how: O …
cropredy's user avatar
  • 73.2k
2 votes

How to write test class for below scheduling code

Because you can't execute more than one Batch in a testmethod, and, you can't insert AsyncApexJob SObjects in testmethods, you could ... You could add to your class... IAsyncJob iGetJobs = new GetPr …
cropredy's user avatar
  • 73.2k
1 vote
Accepted

Help Troubleshoot Codes

Whenever you use Database.update, you need to check the results of the DML as no exception will be thrown if an error (like a validation rule error) Database.SaveResult[] srList = Database.update(def …
cropredy's user avatar
  • 73.2k
4 votes

Can we update fiscal year settings using apex code?

query(), retrieve() nor for that matter is Period describeSObjects(), getDeleted(), getUpdated(), query(), retrieve() While it is true that there are some sobjects that can't be updated via DML in APEX
cropredy's user avatar
  • 73.2k
0 votes

Child record Access in parent child relationship

and even simpler for(Account a: [select id, name, (select id, lastname from Contacts) from Account]) for (Contact c: a:contacts) { system.debug(c.lastname + ' is a contact on ' + a.name); } …
cropredy's user avatar
  • 73.2k
1 vote

First Activity Date

will execute, troll each Oppo's tasks, and update accordingly through the implicit DML of the before update trigger context That said, for one-off, I'd probably do this with Developer Console anonymous apex
cropredy's user avatar
  • 73.2k
3 votes
Accepted

Error: Incompatible element type for collection

The problem is on this line inte.add(numb=i,str='name'+i); you are trying to add an element of type s to the collection inte but you need to call the constructor as part of the list add inte.add(n …
cropredy's user avatar
  • 73.2k
1 vote

Field not retrieved even thought it is referenced in VF page

(V38) The standard controller method getRecord() has implicit access to all fields referenced in the VF markup, including child and parent relationships, and including fields referenced in apex:varia …
cropredy's user avatar
  • 73.2k
2 votes
Accepted

Restrict duplicate contact role on opportunity

OpportunityContactRole can not have a trigger (something oft-requested/seen here in SFSE) The best workaround for this is to use what is called a 'View trigger' on Opportunity detail page. Create a …
cropredy's user avatar
  • 73.2k
2 votes

opportunity how to show the close date show msg close date in near throw on vf page

In addition to the Lightning Experience suggestion from @Raspi, for Salesforce Classic, you can simply create an image formula field that looks like this: IF (TODAY() + 5 = CloseDate, IMAGE("/img/s …
cropredy's user avatar
  • 73.2k
1 vote

Error: Compile Error: Invalid bind expression type of String for column of type Decimal at l...

The clause in your SOQL where Month__c =: month and Year__c =: year and Reference_Number__c =: ref and the error message Invalid bind expression type of String for column of type Decimal at line 3 …
cropredy's user avatar
  • 73.2k

1
2 3 4 5
33
15 30 50 per page