All Questions

Filter by
Sorted by
Tagged with
35 votes
1 answer
47k views

How do I increase my code coverage, or why can't I cover these lines?

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 ...
23 votes
1 answer
6k 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 ...
26 votes
2 answers
27k views

How do I get started working with JSON in Apex?

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 ...
109 votes
11 answers
42k 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 ...
Keith C's user avatar
  • 136k
158 votes
3 answers
27k 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 ...
Rao's user avatar
  • 16.7k
50 votes
3 answers
14k 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 ...
Christian Deckert's user avatar
21 votes
6 answers
46k 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?
168 votes
4 answers
67k 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 ...
Ryan Elkins's user avatar
  • 7,687
53 votes
1 answer
27k 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 "...
Keith C's user avatar
  • 136k
10 votes
1 answer
2k views

How do I bulkify queries for directly or indirectly related records?

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 ...
14 votes
1 answer
3k views

How do I unit test code that includes a callout?

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 ...
19 votes
1 answer
89k views

How to deserialize a JSON String to Apex

How can I deserialize this json object: { "response": { "count": 1, "benchmark": 0.22567009925842, "requests": [ { "request": { ...
codeSlayer's user avatar
15 votes
4 answers
7k 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 ...
user4675's user avatar
  • 233
72 votes
8 answers
68k 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(), ...
Benj's user avatar
  • 11.2k
5 votes
4 answers
29k views

Changing colors of lightning-button

How can I change the colors of lightning-button? I tried doing this in my css: .my-button { background-color: #14a6bc; color: #ffffff; } and applying that class to my <lightning-button&...
BlondeSwan's user avatar
  • 1,098
59 votes
7 answers
39k 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 ...
Shane McLaughlin's user avatar
15 votes
5 answers
33k views

How can I compose a multipart/form-data request?

I'm trying to integrate Kraken.io into our org so I can have Salesforce queue up image optimization jobs that our employees upload. Kraken.io requires that the requests post a multipart/form-data body ...
Gup3rSuR4c's user avatar
  • 1,006
40 votes
5 answers
50k views

Expression Functions for Lightning Web Components

How can expression functions similar to Visualforce and Lightning Aura Components be achieved within lightning web components? For example, <template if:true={index % 5 == 0}><br></...
Oleh Berehovskyi's user avatar
19 votes
1 answer
9k 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?
crmprogdev's user avatar
60 votes
3 answers
32k 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 ...
Ralph Callaway's user avatar
52 votes
6 answers
25k views

Is it possible to test apex that relies on field history tracking?

I have some code that relies on field history tracking by querying the History for a custom object. This works fine, but it appears that the history records aren't created during the test so none of ...
jwolf's user avatar
  • 800
46 votes
6 answers
91k views

Uncaught TypeError: 'set' on proxy: trap returned falsish for property Name

Am not doing anything fancy, just trying to update a field on Contact in JS of LWC but getting this exception. Uncaught TypeError: 'set' on proxy: trap returned falsish for property 'Name' throws at ...
Pranay Jaiswal's user avatar
34 votes
6 answers
33k views

Getting Session ID in Lightning

Background I'm using Apex Wrapper Salesforce Metadata API to update some picklist values on the fly. (i.e. Every time a record is inserted/updated/deleted in Table A, I'm adding/subtracting picklist ...
Jose's user avatar
  • 2,142
22 votes
1 answer
27k views

System.CalloutException: You have uncommitted work pending

I have this exception related to my previous question: System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out When clicking preview as an admin the ...
Ramesh Somalagari's user avatar
16 votes
2 answers
7k views

apex String instanceof Object?

given: Map<String, String> m = new Map<String, String>(); m instanceof Map<String, Object> is always true then why is m instanceof Map<Object, Object> always false?
davec's user avatar
  • 181
63 votes
10 answers
86k 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'];...
Prady's user avatar
  • 12.3k
15 votes
1 answer
9k views

How do I test asynchronous Apex?

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 ...
160 votes
8 answers
37k 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 ...
David Gillen's user avatar
  • 2,997
53 votes
8 answers
37k views

Target inner elements of standard Lightning Web Components with CSS

Say we have a LWC with the following template in a component named example: <template> <lightning-textarea class="test"></lightning-textarea> </template> And some css to ...
Benjamin Vogler's user avatar
38 votes
4 answers
42k 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. ...
Axaykumar Varu's user avatar
27 votes
6 answers
56k 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 ...
18 votes
1 answer
3k 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 ...
Adrian Larson's user avatar
  • 150k
13 votes
1 answer
4k views

External + Named Credential with oAuth client credentials flow

Given: a REST API that requires authorization. The authorization service attached to the API supports oAuth, one of the available oAuth flows is Client Credentials (grant_type=client_credentials) How ...
identigral's user avatar
  • 7,626
12 votes
2 answers
3k views

What is a good pattern for recursion blocking in generic trigger handlers?

Here I'm talking about a handler that covers all the TriggerOperations and that accepts SObjects of arbitrary type. And the recursion problem is where a change caused by a trigger results in that ...
Keith C's user avatar
  • 136k
31 votes
1 answer
93k 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 ...
Teja's user avatar
  • 1,422
11 votes
2 answers
4k 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 ...
PartOfTheOhana's user avatar
140 votes
2 answers
11k 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? ...
Robert Sösemann's user avatar
75 votes
1 answer
6k views

InstallHandler runs under a special ghost user. What rights does it have?

When you install a managed package with a post-install script, Salesforce creates a special ghost user under which all of the post install activities occur. I think this is undocumented. Here are some ...
Matt and Neil's user avatar
49 votes
5 answers
17k 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 ...
Peter Knolle's user avatar
  • 29.1k
44 votes
4 answers
22k 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 ...
Rao's user avatar
  • 16.7k
23 votes
4 answers
20k views

Workbench: read error on connection to ...amazonaws.com when executing SOQL in interactive mode

I was happily using Workbench as usual then after dinner I started receiving error message "UNKNOWN ERROR: read error on connection to ec2-34-194-152-137.compute-1.amazonaws.com:6379" for ...
Robert Wambold's user avatar
2 votes
1 answer
13k views

Trying to automate contact deletion with SSJS

with the GDPR laws in place, it's important to have the possibility to remove contacts from Marketing Cloud. I'm trying to automate the process with existing tools and am looking for possible ...
Rafał Wolsztyniak's user avatar
87 votes
4 answers
54k 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 ...
Swati's user avatar
  • 871
70 votes
5 answers
36k views

How do you deserialize json properties that are reserved words in Apex?

Is there any way to deserialize JSON into an object using JSON.deserialize if some of the property names in the JSON are reserved words in Apex? I want to do something like this: string jsonString = '{...
Greg Grinberg's user avatar
38 votes
6 answers
31k 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. ...
Andy Boettcher's user avatar
125 votes
3 answers
129k 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 ...
ca_peterson's user avatar
44 votes
3 answers
182k views

How to fix insufficient access rights on cross-reference id?

I am getting the error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id: [] Scenario is, I am inserting an Opportunity and then Opportunity Line ...
D-Horse's user avatar
  • 1,955
40 votes
4 answers
13k views

Why is Schema.describeSObjects(types) Slower Than Schema.getGlobalDescribe()?

I was about to reconfigure some of my code to use the newer Schema.describeSObjects(types) method that I had heard was faster than using a globalDescribe. I made some code to quickly check this and ...
Caspar Harmer's user avatar
36 votes
6 answers
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 ...
Uwe Heim's user avatar
  • 28.4k
29 votes
2 answers
7k views

Different Session Ids in Different contexts

I'm trying to implement an OAuth flow from one salesforce instance to another (any other), and one of the issues I've run into is if the other instance has the same instance URL of the "origin&...
Evan's user avatar
  • 481

15 30 50 per page
1
2 3 4 5
229