All Questions

144
votes
3answers
23k views

End of javascript sidebar workarounds? (Salesforce Classic / Aloha)

Reading through this doc: Docs.releasenotes.salesforce We replaced the rich text editor in HTML Area home page components with a new version that supports more markup but doesn’t allow HTML to ...
96
votes
10answers
29k views

How do I start to debug my own Apex code?

Sometimes questions are posted here that would best be answered by helping the questioner learn how to do their own debugging. (Remember that proverb?) I'd like to have something to link to on this ...
46
votes
1answer
14k views

How do I start to debug my own Visualforce/JavaScript?

This question is intended to complement How do I start to debug my own Apex code? as sometimes questions are asked here that could most easily sorted out by the questioner using their browser's "...
43
votes
3answers
11k views

General trigger bulkification - best practices

A general question asked from time to time on stack exchange is question of trigger bulkification. Therefore I have 2 questions: Which best practices are you using? What is the best way to handle ...
124
votes
4answers
29k views

What are Salesforce ID's composed of?

I remember seeing somewhere that IDs are composed of a few pieces. I always have a hard time trying to find that information when I'm looking for it. What I mean by the above is that the various ...
9
votes
1answer
377 views

How do I write an Apex unit test?

This is a canonical question and answer developed by the community to help address common questions. If you've been directed here, or your question has been closed as a duplicate, please look through ...
55
votes
8answers
32k views

Get lists of dependent picklist options in Apex

I have a pair of dependent picklists. In Apex code, how can I determine what options are valid in the dependent field for each option in the controlling field? I've tried using getPicklistValues(), ...
17
votes
6answers
29k views

How to write a unit-test / test class for trigger?

How do I write a unit-test / test class for a trigger? What are my options? Inline with the trigger? New Class?
15
votes
4answers
5k views

System.Exception: Too many SOQL queries: 101 [duplicate]

I am getting a Too many SOQL queries: 101 error on a trigger when I am trying to deploy another trigger. I am posting the trigger which is causing the error. trigger rollupAccountShowings on Account ...
43
votes
6answers
24k views

How can I get a debug log for the sites guest user/public profile? [updated for Spring 18]

Normally, you can put debug monitoring on a user by name to see the details on the error they're getting (especially for the non-descript Error Loading a Visualforce Page). But when you are trying to ...
12
votes
1answer
27k views

How to deserialize a JSON String to Apex

How can I deserialize this json object: { "response": { "count": 1, "benchmark": 0.22567009925842, "requests": [ { "request": { ...
10
votes
2answers
2k views

Parent and children relationships accessible via trigger?

I'm sure this has been addressed before but I can't seem to find the answer. In a trigger on a record, aside from the actual fields on the record, what do I have access to? The parent info? that ...
125
votes
8answers
17k views

Unit testing code which has logic around the CreatedDate

An example of the problem would be trying to test a trigger on a case which will fire on update, and look for time differences between when a case was created and now. Ideally in the unit tests I want ...
27
votes
7answers
52k views

Where To start Learning With Salesforce Development

Where should I start learning? There are various topics to learn like Objects, Classes, Apex, Visualforce, SOSL, SOQL, Triggers, etc. There are so many options out there to start learning. I couldn't ...
39
votes
3answers
18k views

Scheduled reports as attachment

Is there any workaround to send out scheduled reports as Excel attachment than actually embedding it within an email? Salesforce scheduled reports embeds the report in email making further drill down ...
28
votes
2answers
28k views

HTTP Callout from Triggers

I have a trigger on the Custom Object that calls a class. That class makes an HTTP GET request to a Web Service. However I get the following error: Callout from triggers are currently not supported. ...
33
votes
6answers
16k views

Using APEX to assemble HTML Letterhead Emails

I am looking to assemble an HTML Letterhead Email Template for an email service integration project. There are two sObjects that hold this information - EmailTemplate and BrandTemplate. ...
50
votes
10answers
60k views

What would be the best approach to get the recordtype id

I know of two approaches to get the recordtype id of a particular record type Use SOQL RecordType RecType = [Select Id From RecordType Where SobjectType = 'Account' and DeveloperName = 'Business'];...
45
votes
5answers
10k views

How to call a Salesforce REST URL from Lightning Component?

I want to call a Salesforce REST URL from a Lightning Component. Specifically, I'm trying to call this Analytics API URL: /services/data/v32.0/analytics/reports. I see the following error in the ...
35
votes
6answers
4k views

Why do we still need to hack the Sidebar? Usecases - Workarounds - Alternatives

Since it seems to me, that a lot of people still need sidebar workarounds, I would be interested to learn about the use-cases, experienced challenges and (most important) possible strategies to avoid ...
46
votes
2answers
15k views

Lead Conversion Trigger Order of Execution

I've got a project where I'm looking to tweak the standard lead conversion process. Triggers and lead conversion has always been funky in past projects so I was hoping to start the design off by ...
33
votes
2answers
3k views

Ghost Schedulable Classes Blocking Deployment

Recently I've been running into issues where deployments were blocked due to a Schedulable job pending or in progress when I'd already cleared the Schedulable job from that class. Any tips for ...
26
votes
2answers
4k views

Different Session Ids in Different contexts

I'm dealing with quite an unusual issue here, and was wondering if anyone had figured this out. I'm trying to implement an OAuth flow from one salesforce instance to another (any other). And one of ...
16
votes
2answers
19k views

System.CalloutException: You have uncommitted work pending

I have same exception can please Click Here The previous post issue is resolved. Exception: :System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out ...
14
votes
1answer
4k views

Which external Javascript libraries work with Lightning Locker Service?

Components often seem to work with external libraries until the Locker Service is enabled. What libraries work with locker service enabled and where can I go to find out?
117
votes
2answers
23k views

How to reduce a large internal view state / what is in the internal view state?

I'm building an account search page that lets users select accounts and then pass them to other pages to perform various actions on them. Unfortunately users are reporting hitting the view state ...
93
votes
3answers
50k views

How can I efficiently generate a Set<Id> from a List<SObject> structure?

I have a bit of code where I've written a SOQL query that returns a list of SObject records, however I need a Set<Id> structure to pass to another method that I don't have control of (and thus ...
19
votes
2answers
18k views

How can i integrate one SFDC org to another SFDC using Rest Api

I am trying to integrate one Salesforce org to other org by using Oauth setup, I wanted to use use consumer key and consumer secret key in my REST class to connect with the org, after connection part ...
39
votes
4answers
1k views

Why Are Data Silos Important in Unit Tests?

I have a lot of strong opinions about this issue, but had a hard time finding official documents today to back up my position. A lot of times we say it is bad practice to use seeAllData=true, but we ...
19
votes
1answer
48k views

Can anybody explain the UNABLE_TO_LOCK_ROW error?

Error Message: Developer script exception from Nicomatic : quotepotential : quotepotential: execution of AfterUpdate caused by: System.DmlException: Update failed. First exception on row 0 with ...
14
votes
1answer
627 views

Set Relationship Via Name Pointing Field?

One of the most startling things I ever learned from @BobBuzzard is that you can update a lookup by using the name pointing field. At least, I thought that's what I learned, until a recent debate cast ...
5
votes
1answer
767 views

Formula Specific to Running User?

I have a requirement where a certain field can be edited without the validations firing for a particular user. Now I tried to write rule like LastModifiedId != '005000000000000AAA' but the validation ...
48
votes
1answer
11k views

Is there a way to do Like against a list of Values?

Is there a way to mix LIKE operator with IN ? Something Like SELECT Id FROM Account WHERE Name LIKE IN:nameList Where nameList is list of String? Is this is possible ? (I can make a dynamic query by ...
51
votes
6answers
24k 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 ...
35
votes
3answers
45k views

Difference between controller and extensions

Can any one explain the usage of controller and extensions in Visualforce? In which scenario we have to use controller and extensions? Thanks in advance
54
votes
2answers
4k views

Salesforce, Oracle and the Seven Dwarfs

Over my time as a Salesforce developer, I've written some code which on occasion managed to surface Oracle plsql exceptions and curiously the error text contains the name of one of Disney's Seven ...
16
votes
3answers
7k views

Lightning - How to use force:inputField?

I've seen that since Spring'15, there are new standard components available in Lightning. I've been looking for a component that would be a sort of apex:inputField, but in Lightning. The force:...
4
votes
1answer
763 views

Help on Invokable Apex Test class and @Future callout Apex test Class

I am pretty new to Apex and trying to learn as much as possible. Any help would be really appreciated. I have two classes. Invokeable Apex Class: This class is just getting called by a Process (...
71
votes
7answers
11k views

Apex static code analysis

What static code analysis tools are there for apex? The only one I seem to be able to find is the Force.com Security Source Code Scanner but that has the draw back of placing your request into a queue ...
76
votes
2answers
12k views

Has anyone, ever, successfully invoked the Metadata API from within Apex?

While researching a semi-related question posted here earlier, I dug up some interesting and conflicting information regarding whether it's even possible to use the Metadata API from within Apex. I ...
33
votes
3answers
7k views

How to deploy apex classes that are scheduled

This is related to Is there any way to unschedule an apex scheduled job programmatically?. I noticed user320 mentioned there is a way to use Type.forName to decouple your classes from the scheduled ...
29
votes
3answers
18k views

How to use fieldsets with Lightning?

Been trying to figure out how to create a salesforce Lightning input form, based on fields from a fieldset. As an aura enabled apex method is not allowed to pass an entire fieldset I tried by ...
25
votes
1answer
17k views

Error: MIXED_DML_OPERATION on setup and non-setup objects

In my test class i have the creation of a dummy custom setting and a dummy lead: Group g1 = new Group(Name='group name', type='Queue'); insert g1; QueuesObject q1 = new ...
54
votes
4answers
30k views

SFDC: Understanding With Sharing, Without Sharing & Unspecified Sharing Classes

Per my understanding of With Sharing, Without Sharing and non-sharing-specified Classes in Apex, I would like to jot down the following notes and leave certain blanks for not sure answers; I wanted to ...
43
votes
2answers
9k views

Changing the color of a custom button

Is there a way of changing a custom button color? Not a button on the visualforce page but rather the ones created under custom and links on an object. Thanks. -K
46
votes
4answers
49k views

How to run a scheduled job every 15 minutes?

Using the salesforce GUI it seams impossible to schedule a job every 15 minutes. Or more than once a day.
19
votes
2answers
44k views

how to get a picklist all values in apex controller

I have a Student object and have a pick list field "Student Status" in this object. Status can be Full-Time OR Part Time. Now my requirement is i want this student status list, Part-Time or Full-Time ...
26
votes
2answers
7k views

How to set up views and navigation in Lightning?

What is the best way to create views in Lightning? And then, how would you navigate from one view to another? Conceptually I'm thinking that I'll have two components, ns:foo and ns:bar, and ...
83
votes
3answers
3k views

Any reason to skip DML on empty lists?

In parts of my code I have DML statements with an if around to only do the DML if the list is not empty: if( !recordsToUpdate.isEmpty() ) { update recordsToUpdate; } Couldn't I just write? ...
40
votes
7answers
25k views

How Can I Tell the Day of the Week of a Date?

I'd like to build in some logic based on the weekday (e.g. Monday, Tuesday, Wednesday) of a given date. How can I identify the date, using either formulas or Apex code?

15 30 50 per page