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
9
votes
1 answer

Sending email with template using trigger

I have the following Trigger: trigger send_notification on Inquery__c (after update) { Inquery__c inquery = trigger.new[0]; String[] toAddresses = new String[] {inquery.email__c}; Messaging.SingleEmailMessage mail = new…
user2333346
  • 1,083
  • 4
  • 21
  • 40
9
votes
1 answer

Need Salesforce API detail to create lead in salesforce CRM from my website(PHP)

Friends, I have a contact us/Inquiry form in my website. I want to generate a lead in Sales force CRM on submission of this form. What I have tried ? I have checked in salesforce doc and Google it I found…
Javascript Coder
  • 5,691
  • 8
  • 52
  • 98
9
votes
2 answers

How to achieve nested conditional rendering without empty span tags from apex:outputPanel?

I am trying to generate clean XSL-FO from a VisualForce page. But the xml coming out of the VisualForce page is not valid due to the empty span tags that are being generated by nested apex:outputPanel tags (outer rendered=true, inner…
twamley
  • 801
  • 2
  • 14
  • 22
8
votes
1 answer

Does salesforce Apex support inheritance of static methods?

public virtual class parent { public static void doStuff(){system.debug('stuff');} } public class child extends parent{} When I call child.doStuff(); I get this error: Method does not exist or incorrect signature: child.doStuff() Are static…
naomi
  • 1,934
  • 1
  • 14
  • 29
8
votes
2 answers

How do we schedule a class to run every 15 minutes in salesforce?

I am trying to schedule a class to run every 15 minutes. I know we can set in salesforce for every hour, but is there a way to reduce the granularity to 10-15 minutes? global class scheduledMerge implements Schedulable { global void…
Prady
  • 10,978
  • 39
  • 124
  • 176
8
votes
2 answers

Apex Code Version Control

Is there any way to integrate version control system for Apex & Visualforce code? I can thinking of keeping a separate repository but no way to have it integrated with Salesforce Platform. Thanks in Advance.
Mitul Makadia
  • 398
  • 6
  • 24
8
votes
3 answers

Building OLAP style applications with SalesForce/Apex

We are considering moving a planning and budgeting app to the Salesforce platform. The existing app is built on a dimensional data model, and has extensive ad-hoc query capability implemented through star joins. We see how the platform will allow…
Old Man
  • 3,295
  • 5
  • 23
  • 22
8
votes
7 answers

SOQL query WHERE Date = 30_days_ago?

How do I make a SOQL query like this? SELECT id FROM Account WHERE LastActivityDate = 30_DAYS_AGO This produces an error: MALFORMED_QUERY: Account WHERE LastActivityDate = 30_DAYS_AGO ^
Dave S
  • 599
  • 2
  • 8
  • 17
8
votes
1 answer

array length in Salesforce

I'm getting error "Error Error: AddIMRConroller Compile Error: Initial term of field expression must be a concrete SObject: LIST at line 21 column 23" from below line of code . string[] str1 = imrTable.split('\r\n'); System.debug(…
Raj
  • 1,698
  • 4
  • 22
  • 39
8
votes
1 answer

Parsing JSON Object in Salesforce Apex

How do I parse a jsonObject which is in a given format in Apex? I need List from the items array which contains the id attribute. What is some appropriate method? For parsing it, I try to create a class with code: public class JSON2Apex { …
mathlearner
  • 7,509
  • 31
  • 126
  • 189
8
votes
2 answers

How to exit an apex function?

I have an apex function which has a void return type. I want to exit the function at a specific position. Is this possible in apex without changing return type pagereference?
Yogini Mane
  • 185
  • 2
  • 2
  • 8
8
votes
2 answers

No refresh_token in SalesForce OAuth Response

I'm interacting with a custom APEX service which obviously require OAuth authentication. I can easily authenticate and authorise my application. Everything works fine. However, the access token I receive tends to expire. Of course, I can refresh it…
Mike Borozdin
  • 1,138
  • 3
  • 14
  • 32
8
votes
1 answer

Can you programmatically determine if a user is licensed for a package?

I am using the LMA (License Management Application) and want to know if it is possible to programmaticaly tell if a user has been licensed for my package. Imagine if I wanted users of the application to see each other's application specific data -…
Ryan Elkins
  • 5,731
  • 13
  • 41
  • 67
7
votes
4 answers

How to implement "Cancel" functionality in a VisualForce Page

I know that this is how to save a record I want a button to NOT save the current record (ie. Cancel) and navigate to the list of saved record (ie. list of objects for that object type). Something…
Sam
  • 2,663
  • 10
  • 41
  • 60
7
votes
1 answer

After Update Trigger pending Approval request OriginalActorId

The trigger below is built to pull the most recent "assigned to" user (or OriginalActorId) from the approval process list, the Approval_started__c field is checked as an initial submission action from a specific approval process. The issue I have is…
Sam
  • 487
  • 4
  • 12
  • 31