Top "Apex" questions

Apex is a strongly typed, OOP language that allows to execute flow and transaction control statements on the Force.

Is the SWITCH and CASE statement supported in APEX in Salesforce?

Instead of this basic structure with IF / THEN / ELSEIF / ELSE int month = 8; String monthString; if (month == 1) { monthString = "January"; } else if (…

salesforce apex
FIELD_CUSTOM_VALIDATION_EXCEPTION

I am writing a test class for a trigger. But i am not able to run it properly it only …

salesforce apex
How to insert data into a custom object with lookup field from apex controller

I have a custom object MyCustomObj__c which has a field called "ContactData". I am trying to insert a record …

salesforce visualforce apex
First error: INVALID_CROSS_REFERENCE_KEY, Assigned To ID: owner cannot be blank: [OwnerId]

I am writing a test for my controller. For that I have to insert an event in the test database. …

salesforce apex-code apex soql
Apex - Subtract minutes from DateTime Object

I'd like to subtract 5 minutes from DateTime.now() May I know how I can do this? Thanks!

datetime salesforce subtraction apex
Custom Exception Message in apex Salesforce

I want to create a custom exception. In this exception I want to make a constructor which take one string …

salesforce apex-code visualforce apex
Apex Triggers - Trailhead

The code itself doesn't give any errors, but anytime I run it Trailhead gives me this message: "Challenge not yet …

triggers salesforce apex apex-trigger
Need Help to Overcome Apex CPU time limit exceeded Error

I am working on a module which will de-duplicate contact records on insert/update but I am hitting into Apex …

salesforce apex-code visualforce apex force.com
How can I get subList of a List in Apex Salesforce?

I have got a list of SObjects having N number of items/sObjects SObject[] sList = [sobject1, sboject2, sboject3, ........ , sobjectN] How …

list salesforce apex-code apex sublist
Multi Level Nested JSON Parsing with Apex Salesforce

Can I parse Multi-Level nested JSON structure in APEX Salesforce, like we do in Java with GSON and Jackson libraries? { "…

salesforce apex-code apex