Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [apex]

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.

4
votes
1answer
643 views

List controllers are not supported for Profile

Is there a workaround for "List controllers are not supported for Profile" error in visualforce page? Am creating a simple visualforce page to display the profiles in a data table with the pagination ...
10
votes
1answer
2k views

Time limit exceeded and 'Response size exceeded 30MB organization limit' and Semi-join subselects not allowed

Am getting a time limit exceeded error when am trying to pull a set of records through database.getquerylocator and binding it to vf page (jqgrid). I have about 80000 records but am limiting it to ...
32
votes
4answers
6k views

Documenting Salesforce.com Apex class files

[I asked this question on Stack Overflow but didn't get any answers there.] Since the Salesforce.com Apex language is "Java-like", I'd like to use javadoc or Doxygen to generate API documentation for ...
46
votes
3answers
19k views

Why use Batch Apex?

What is the point of batch apex? I've been trying to do some research but everything I find just tells me how to use it or goes over scenarios where it might be useful - without telling me why I would ...
2
votes
3answers
3k views

How to find Knowledge Article Type?

I am querying the KnowledgeArticleVersion table to list all articles in order to display a list of links to articles. Because of some limitations I cannot use the <knowledge:articleList> tag. ...
4
votes
1answer
562 views

How do I direct my case view to the shortened URL?

I have a <apex:pageBlockTable> to display a list of cases like this: <apex:pageBlockTable value="{!case}" var="c" rows="50" id="cases_table" > <apex:column > <a ...
5
votes
2answers
1k views

Apex SOSL Paging Implementations

How might one implement SOSL paging, i.e. get the next 200 results, in Apex?
59
votes
5answers
15k views

What is a good set of naming conventions to use when developing on the Force.com platform?

I've looked in the Apex developer's guide and a saw the Naming Conventions section which has basically only has this: We recommend following Java standards for naming, that is, classes start with a ...
11
votes
2answers
2k views

What are the recommended ways to refactor in Apex?

I had to rename a class or two and I'm used to the Eclipse refactoring capabilities which update all references as part of the name change. In Salesforce the rename is not supported in the IDE (v 25),...
16
votes
5answers
8k views

Resize Image in Photo Upload in Visualforce before save in attachment?

Good Morning Friends, I am creating a Visualforce for my users to upload photos and these photos are saved in the attachments object, but I wonder if there is any way before the picture is saved I ...
14
votes
1answer
4k views

Mimic MySQL AES_ENCRYPT in Apex

I am trying to mimic the MySQL AES_ENCRYPT function in Apex code. However the issue I am having is that MySQL doesn't use an initialization vector. Is there a way to replicate this behavior in Apex? ...
2
votes
1answer
241 views

How are wsdl2apex generated private member variables referenced?

When generating apex code through a WSDL, several classes and member variables are generated. Each data type has its own class and the class has at least two private member variables associated with ...
2
votes
2answers
7k views

How do I sort cases using a pageBlockTable?

I have a Visualforcepage with an apex:pageBlocKTable displaying Cases. I am trying to add the ability to sort the cases by CaseNumber. I looked over this wiki page: http://wiki.developerforce.com/page/...
14
votes
6answers
8k views

Why is the count() query in salesforce not counting the no. of query rows returned as 1?

Sample code on a custom object, Asset__c, containing 78,000 rows: Integer number1 = [SELECT count() FROM Asset__c ]; system.debug('Query Rows used by count():'+Limits.getQueryRows()); If i do this.....
0
votes
2answers
1k views

Display Articles in a tree like structure

I am trying to create a VisualForce page where I display our articles in a tree like structure. There are only 2 levels in the tree, so like: +Root ++Geography ++Politics ++Economy There are ...
5
votes
2answers
2k views

Which object stores Content Library-Members list?

Which object stores Content Library-Members list? I need to find if current logged in user has just read(Viewer) access to a Library or write(Admin/Author) access.
12
votes
4answers
17k views

How to query more than 50000 records in apex and bind it in vf page in jqgrid and paging?

How to query more than 50000 records (78000 records) in apex and bind it in vf page in jqgrid and implement paging in it? I tried querying through SOQL and assigning it to list.. Am unable to query ...
9
votes
7answers
3k views

Is it possible to create a reusable inline Visualforce page?

I'm working on a Visualforce page that (forgetting about page layouts for a moment) takes in a Record Id (from one of a variety of objects), does some querying for Content based on that Record Id, and ...
9
votes
1answer
3k views

Authenticate 3rd party Application with OAuth2

The PHP getting started guide for interacting with Force.com seems to indicate that a user always needs to reauthenticate for each session with OAuth2, and that's my understanding of the protocol as ...
7
votes
3answers
3k views

Apex: Calculate hour ranges

Given a start time (datetime) and a finish time (datetime) how can I easily calculate the number of hours that fell between 6:00am - 12:00pm (day hours) and 12:00 - 6:00am (night hours). They would be ...
6
votes
4answers
1k views

Generating notification for user to confirm that a field has the correct value

I have a custom field called Pipeline which is a required Yes/No picklist that defaults to No. When the user makes some specific changes to the record, and Pipeline=No, I would like them to confirm ...
6
votes
4answers
4k views

Isn't ContentVersion 'VersionData' Updateable (Amendable)?

I'm developing an file (attachments/contents) upload app and the process of my upload is that I upload file in chunks to ensure I'm not hitting view state. For first chunk insert new attachment ...
7
votes
2answers
7k views

Create Chatter post with mix of HyperLinks and text in the Body (in Apex code)

How to create a chatter post in the body I want to add Links in between. (in Apex code) its not complete link or complete plain text. I am looking at mix of both Example Chatter post - just has ...
2
votes
1answer
111 views

Triggering to check for changes in org level sharing rules

Does anyone have a solution for checking for changes in sObject__Share settings on particular objects in APEX
6
votes
2answers
5k views

Retrieving custom fields from a standard controller in an extension

How do I retrieve custom fields from a standard controller in a Visualforce extension controller? In the code below, if I remove the hard-coded ID "this.personParentId = '001Z000000CkZ4m';", it fails ...
6
votes
3answers
979 views

Is there some way to view a history of anonymous block executions?

I use the Force.com IDE and sometimes execute anonymous blocks of code through the Execute Anonymous view. I have used other tools like SQL Developer from Oracle and they keep a persistent history of ...
18
votes
1answer
7k views

What are the implications of implementing Database.Stateful?

I've recently implemented a batch apex class that initially did not implement Database.Stateful. After using it for a while as-is I decided to implemente better error handling via a simple Map to ...
5
votes
1answer
3k views

Create a custom object via the API (define the object, similar to DDL)

I was looking through the Metadata API (and Partner) but can't find anywhere described how I can define via the API a custom object. We have specific datasets which have to translate into Custom ...
36
votes
8answers
4k views

Is there a way to setup continous integration for apex tests?

I would like to have continous integration (with Jenkins) for my apex code in order to run them automatically after each push to my git repository. Does anyone know a way how to do that?
10
votes
3answers
4k views

Optimal way to get Case.Id from Case.Thread_Id

We've implemented a custom Apex Email Service to extend the standard Email-to-Case functionality, and one area we're struggling to do efficiently is figure out the CaseId when all that is known is the ...
4
votes
1answer
1k views

PageLayouts and Fieldsets in APEX

We've repeatedly tried to figure out ways to display a Pagelayout and/or FieldSet settings in our custom VF pages without having to rely on the standard controller. For example to display a fieldset ...
4
votes
1answer
245 views

How to get Chatter limits in apex?

There is currently a limit that a single user can only follow 500 entities on Chatter. This is very low for a Social Enterprise, in my opinion, and I figure that it will have to get increased once ...
7
votes
1answer
4k views

Handling Record Errors in a Batch Process

How does one handle individual record errors in a Batch Process? Tried the following example below, but once I iterate through wlist after the batch has completed (checking the job status through an ...
10
votes
5answers
1k views

RemoteAction Insert Error: “Please provide an id or sobjectType value”

I posted this to Twitter a couple of times but I'm still stumped. I have an Apex class called "TestRemoteActionClass" with a method marked as a @RemoteAction that looks something like this: @...
3
votes
3answers
277 views

API Limits Exception

We have a customer whom is hitting API limits in their org: More than 50,000 API call per-day. They're trying to isolate an installed package that might be to blame, and the only thing they've given ...
2
votes
1answer
343 views

Creating a method that ensures safe HTML input

We're building an app that requires the user to be able to input raw HTML (for a design template) and then be able to display that within SFDC. The challenge we've found in a security process is that ...
13
votes
2answers
3k views

Using transient keyword to store password in hierarchy custom setting

Per a security review, we've found that the use of transient keyword is required to store variables within custom settings. There's a great link that's been provided to help us get pointed in the ...
5
votes
2answers
1k views

How do you deprecate a global method in a managed package?

This is semi-related to another question of mine: Is there any way to clean up redundant tabs/settings/pages/etc from managed packages? However, it is a bit different. Once you've added a global ...
7
votes
2answers
4k views

Case Assignment Notification Suppression

I am trying to determine if it is possible to suppress the Case Assignment Notification email from within a Before Update Trigger. Or confirm that this is a newly introduced bug since I believe I was ...
16
votes
1answer
6k views

What are the best practices for using polymorphism in Apex?

Apex provides at least two different methods for polymorphism (that is, writing code that can use objects of different classes in a uniform way): Standard inheritance-based polymorphism, where code ...
22
votes
5answers
6k views

What is an easy (and fast) way to find a object named based on a parentid?

I have an app which is fired from a trigger on FeedItem and FeedComment. I can easily grab the posting user, date, parentid and type. However I am finding it difficult to rapidly determine the object ...
2
votes
2answers
639 views

Workflow not evaluating to true when it should

I have a Workflow on Leads, which is a formula (also tried as a Filter), the content: Days_from_Creation__c = 1 && HasOptedOutOfEmail = False && My_Drip__c = null This is from the ...
7
votes
4answers
2k views

Run anonymous apex as if it were a test case

Is there any way to run anonymous apex so that it is treated the same way as a unit test? Sometimes it would be ideal to just try some code out and know that any DML operations that get performed won'...
24
votes
2answers
2k views

Is there a defacto 3rd party utilities library for Apex such as Apache Commons is for Java?

I have been developing in Java for some time and have grown accustom to using third party libraries such as Apache Commons for some of the more mundane functions needed in most applications (e.g., ...
10
votes
1answer
2k views

Deleting a class without IDE

Salesforce makes it hard to delete classes in a production org. Our change control policy doesn't allow for the use of the IDE to make changes to the production org...everything goes through change ...
7
votes
4answers
3k views

Linking CronTrigger sObjects to Scheduled Jobs listings

When using System.schedule to add apex jobs to the scheduled jobs listing it creates a CronTrigger sObject containing the expression determining when the job is set to run. However this CronTrigger ...
10
votes
6answers
2k views

How do you unit test a trigger when you don't know the required fields?

This is another issue addressed largely towards app developers. Let's say I write an insert trigger. When I write the test case for it, what I would normally do is create a new object, insert it, and ...
5
votes
3answers
1k views

Getting LastModifiedDate of Admin changes

Let's say you have a details page of a Contact. I would like to be able to track changes that were made to Contact, such as field name changes, field type changes, etc. I assumed that there ...
4
votes
3answers
833 views

Is there any way to clean up redundant tabs/settings/pages/etc from managed packages?

I have a mangaged package that has seen a lot of updates over time. Some parts have become redundant and aren't used at all anymore. However, with SFDC's rules about managed packages, many of these ...
51
votes
6answers
23k views

Can report data be accessed programatically?

Is there any way to access existing reports and their data to be used in apex? Sure, I could write the SOQL manually but if I want it to mirror a specific report I would have to make code changes ...