Questions tagged [apex-code]

A proprietary Java-like programming language for the Force.com Platform, not to be confused with Oracle's Application Express (oracle-apex).

From the Salesforce.com page What is Apex?:

Apex is a strongly typed, object-oriented programming language that allows developers to execute flow and transaction control statements on the Force.com platform server in conjunction with calls to the Force.com​ API. Using syntax that looks like Java and acts like database stored procedures, Apex enables developers to add business logic to most system events, including button clicks, related record updates, and Visualforce pages. Apex code can be initiated by Web service requests and from triggers on objects.

For questions that are related to this tag you can use shorter tag - .

(Please use to refer to Oracle Application Express.)

Useful links:

Force.com Apex Code Developer's Guide

1514 questions
6
votes
3 answers

Salesforce Apex Trigger "isAPI" Context Variable

Is there a way to determine if a trigger is being executed by an API call or through the Salesforce Web Interface? I'd like to do something like this: trigger Update_Last_Modified_By_API on My_Object__c (before update) { for (My_Object__c o :…
Greg
  • 8,574
  • 21
  • 67
  • 109
6
votes
2 answers

Salesforce: Avoiding governor limits in Test classes across the board

I have not been able to get any reliable information about this issue online. But I think it must be an issue which must be affecting a lot of people. Basically I wrote a simple trigger and test class in sandbox, tested it and when it was fine I…
Richard N
  • 895
  • 9
  • 19
  • 36
6
votes
4 answers

How to show only extracted error message from Custom Validation on a Visualforce Page?

I have added few custom validations using Configuration for an object. I am inserting that object record through visualforce page. I have added on my visualforce page. I have also written code block for catching the exception…
kshitij
  • 63
  • 1
  • 1
  • 3
6
votes
3 answers

How to get just the system.debug output when executing code?

I wrote a simple program and want to see the output when I run the code. When I run it in the force.com IDE using the 'Annoymously execute apex code'command I get a lot of unwanted results, when I only want the system.debug statements. I could do…
PartOfTheOhana
  • 667
  • 2
  • 16
  • 40
5
votes
2 answers

What time zone does a scheduled job use for Preferred Start Time

We have a scheduled job that runs on the 1st of each month with a Preferred Start Time of 1am. The job was scheduled using the Salesforce interface (Develop | Apex Classes | Schedule Apex). When it runs, it sets a month field for records based on…
Matt K
  • 7,207
  • 5
  • 39
  • 60
5
votes
3 answers

Why are HTML emails being sent by a APEX Schedulable class being delivered with blank bodies?

I have an APEX class that is used to send an email out each day at 7PM: global class ReportBroadcaster implements Schedulable { global ReportBroadcaster() { } global void execute(SchedulableContext sc) { send(); } …
barelyknown
  • 5,510
  • 3
  • 34
  • 46
5
votes
2 answers

Create multiselect lookup in salesforce using apex

I want to create a multi-select Contact Lookup. What i want : When user clicks on a lookup then he should be able to select multiple contacts from that. What i have done: I have created an object and a field inside that object using both "Lookup"…
Swati
  • 2,870
  • 7
  • 45
  • 87
5
votes
3 answers

How to get in a Visualforce page controller a value from a custom component controller?

I'm trying do develop a visualforce custom component which is an entity chooser. This custom component displays a UI which helps browsing some records. It's possible to select one record, and I'd like to get it from outside the component or its…
hrobert
  • 53
  • 1
  • 1
  • 5
5
votes
4 answers

Where do I add a trigger for "Notes and Attachments" in salesforce.com?

I cannot find where in the salesforce.com UI I can add a trigger on a file attachment. I can find triggers on almost everything else, but attachment seems to be missing from the list (even when I view source on the page and search it. Does anyone…
boatcoder
  • 17,525
  • 18
  • 114
  • 178
5
votes
4 answers

Salesforce Session variables, set and get variables in Session

I want to be able to read / write some variables to the current session in my Salesforce site pages. I have a site built using Salesforce Sites, I need to store/retrieve some values across all the pages (consider that I am building something similar…
Tea Bee
  • 401
  • 2
  • 8
  • 18
5
votes
2 answers

Is there a way to serialize/deserialize Apex object properties with a different name?

I'm part of a team building an API wrapper in Apex. Our service responses use snake case, but we wanted to follow style conventions and use camel case for our Apex variables. If the names don't match, however, the properties won't get set correctly…
Logan Patiño
  • 91
  • 1
  • 10
5
votes
2 answers

Salesforce/SOQL - Given child, how to return "top level" parent account?

I have an issue where I need to find the top level parent account for a child. The best I've been able to do is filter up from the child w/ SELECT id, name, parent.id, parent.parent.id, parent.parent.parent.id, FROM Account WHERE…
Dave S
  • 599
  • 2
  • 8
  • 17
5
votes
1 answer

Test.loadData with Custom sObject Throws Exception

I am loading a CSV file via Static Resourced to test my APEX code. I am using the following code in my test: List territoryData = Test.loadData(Territory_Zip_Code__c.sObjectType, TERRITORY_ZIP_CODES_STATIC_RESOURCE_NAME); The…
Swisher Sweet
  • 769
  • 11
  • 33
5
votes
2 answers

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 can I get just 10 items from the begining of the list Thanks in advance!
user3534513
  • 85
  • 1
  • 2
  • 5
5
votes
1 answer

Searching for the instance of global variable $Label in salesforce

My code in gobal footer component - It is displaying in page"© Copyright 2012 " I am new in Salesforce. I just want to modified text with "© Copyright 2013 " In place…
Javascript Coder
  • 5,691
  • 8
  • 52
  • 98