Stack Exchange Network

Stack Exchange network consists of 175 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.

15
votes
0answers
178 views

Custom Labels in Packages - Potential BUG in Winter 19 (Confirmed as Know Issue by Salesforce)

We have an unmanaged package using 167 custom labels to use the Translation Workbench in Salesforce and to be able to translate texts into different languages. Until now, all our custom labels have ...
14
votes
0answers
1k views

Using apex class as attribute type for component - Summer '14 IDE issue

I have a component that gets an instance custom Apex Class as an attribute, ie: <apex:component controller="ComponentController"> <apex:attribute name="myAttr" assignTo="{!attr}" type="...
11
votes
0answers
1k views

Managed Package error “Dependent class is invalid and needs recompilation”

I'm getting an exception email from a client who has installed my Managed Package in his org. The error message I receive is: Apex script unhandled trigger exception by user/organization: ...
10
votes
0answers
205 views

toLabel in @AuraEnabled Apex Lightning controller

The SOQL toLabel function doesn't work in my @AuraEnabled method when called from a Lightning component. UserInfo.getLanguage returns "fi" (for Finnish) but the Record Type Name field that's supposed ...
9
votes
0answers
712 views

Error parsing json response: 'expected expression, got '<''. Logged in?

I'm calling a remote action which returns a wrapper. It works without any issues on most of the time. But sometimes, it throwing an error: Error parsing json response: 'expected expression, got '&...
8
votes
0answers
89 views

Cache.Session not honoring ttlSecs argument?

I'm using session cache and trying to set the TTL (lifetime) to 60 minutes. However it is expiring much more quickly (it appears to be using the default 5 minute expiry). The docs say TTLs is ...
8
votes
0answers
88 views

@deprecated annotation issue in Managed Apex

We have 2 managed packages. Let's name those MPMAIN and MPCHILD. MPCHILD package is dependent on MPMAIN. In MPCHILD we have a class: @deprecated global class ChildClass extends MPMAIN.MainClass { ...
8
votes
0answers
252 views

Spring 18 breaks overridden apex methods in lightning components

We have an overridden @auraEnabled method that returns an array of custom apex class objects with @auraEnabled get methods. This has worked since it was built. However, one of our customers just ...
8
votes
0answers
181 views

Salesforce doesn't merge fields on email sent in platform event context

I have a process that runs every day in the morning. It is a scheduled class that publishes a platform event. When this event is run by the system, it collects some records and sends emails to some ...
7
votes
0answers
45 views

Rethrowing an exception is missing the stackTraceString

I have code that is wrapped into a main try-catch block and then inside of that I have another try-catch which I am using for a specific use case. If the inner try-catch gets triggered I then use a ...
7
votes
0answers
61 views

QuickAction.DescribeQuickActions Broken In Managed Packages

QuickAction.DescribeQuickActions() will return different results when called from a managed package context and unmanaged code. For a given entity type, for example Contacts, you must call ...
7
votes
0answers
259 views

Total Batches increase during the run of a batch (again)

I experienced a batch that changed (increased) the #TotalBatches during its execution. 104 total batches Reload. 106 total batches I experienced this year ago (see this question Total number of ...
7
votes
0answers
157 views

Exception during Inserting attachment from managed package

I'm working on managed package and I have to insert Attachment record from my apex code. The code is pretty simple, that's just create and insert Attachment, something like that: Attachment ...
7
votes
0answers
1k views

Email chatter followers on every post to record

I want to email all the followers of a record anytime anyone posts to the chatter feed. I assumed this would be simple but it doesnt seem to be built into the system? It seems like im gonna have to ...
7
votes
0answers
544 views

Trigger page message in the parent page from the Controller Extension of a custom list view button

Is there any way to trigger the display of a page message in the embedding Detail page from the Controller Extension of a Custom list view button? I create my list view buttons with this technique ...
6
votes
0answers
344 views

Why does SOQl query for Owner.UserRole.Name on Opportunity cause error in Opportunity Territory Assignment apex class

I've been working on an Apex class to do our Opportunity territory assignments based on the example here. I needed to modify it to support our rules that included checking the User Role on the ...
6
votes
0answers
64 views

Is there is any way to get standard field api name from standard report types reports in apex?

I want to get the api name of the standard field being used in Reports of Standard report types. I used describe methods to get the columns used in a report. I analysed some of standard reports ...
6
votes
0answers
205 views

What headers are returned in RestRequest.headers property?

Question Is there an official list of which headers are returned when using the RestContext.request.headers property? Background I know that the returned data is limited, e.g. it excludes the ...
6
votes
0answers
2k views

ContentDocumentLink Apex after insert trigger error

Edit: I've built an after insert trigger on ContentDocumentLink. On cropredy's direction, I've bulkified my code and I think improved it generally. It "works" in that it accomplishes my business ...
6
votes
0answers
621 views

Apex equivalent of REST api's nextRecordsUrl

When you run a query through the REST api and the number of records returned exceeds the default 2000, or the batch size set in the Sforce-Query-Options header, the query will return a nextRecordsUrl ...
6
votes
0answers
376 views

“Variable not visible” error in production, but fine in development

My managed package works fine in development. When it runs from client orgs, as an installed managed package, this error occurs: "VisualForce Error Variable is not visible: [PackagePrefix....
6
votes
0answers
75 views

What's happening upon deletion of a Group record

I just ran a few consecutive tests of inserting and deleting a bunch of groups via the developer console (execute anonymous). Inserted 50 Group records: List <Group> groups = new List <...
6
votes
0answers
435 views

How to retrieve connected app using metadata API?

I have created connected App using metadata API,Now I have to retrieve connected App's Information using metadata API,The code is working fine for the Apps which is created manually but not for the ...
6
votes
0answers
1k views

What does '?scontrolCaching=1' mean in a URL from a Visualforce page?

I have a custom list button on the Account object that, once clicked on, auto-navigates a user to the defined Visualforce page which uses the Opportunity standardController. I notice in the URL, it ...
5
votes
0answers
38 views

Issue with receiving HTTP with Content-Type:application/x-www-form-urlencoded

I've faced a strange issue during my development related to the API. My goal was to create a web service that will receive POST requests from different sources. First service: It passes all the ...
5
votes
0answers
136 views

Apex trigger takes a lot of time to access items in list

I have a simple Contact trigger in a sandbox org that is exhibiting some serious performance issues. After doing some debugging it looks like the issue boils down to accessing the items inside Trigger....
5
votes
0answers
65 views

How to create custom rules for PMD Apex static code analyzer?

How can I create custom rules for PMD? For example, if I want to create a rule to say 'all code should be in allman style and therefore, any line with { should be the only character on the line', how ...
5
votes
0answers
140 views

Test Failed 'Validation Errors While Saving Record(s)' when loading Accounts with Test.LoadData

Background When I use the Test.LoadData method to load Account records: List<Account> accountList = (List<Account>) Test.loadData(Account.sObjectType, 'account_test_data'); I get this ...
5
votes
0answers
261 views

Named credential does not work with client credentials

I have read the full documentation and have few questions on how named credential works. I have written a custom provider like this: /** * Description of the class * <p /><p /> * @...
5
votes
0answers
91 views

No DML_END Issue

Yet another "what gives" question. I have a custom object that is updated upon a button click on a VisualForce Page. I can see in my debug logs that the object has been updated. But when I refresh ...
5
votes
0answers
467 views

Test cases failing with “Could not run tests on class 01pXXX because: connection was cancelled here”

When running all the test classes in my dev org I'm getting intermittent failures on some of them with: Could not run tests on class 01p400000000001 because: connection was cancelled here The ...
5
votes
0answers
311 views

Visualforce Remoting: Javascript proxies were not generated for controller QuoteLayout: may not use public remoted methods inside an iframe

I've looked at all of these solutions here on SFDC stack exchange (1) (2) (3). I followed them for what applied to what I'm doing and I'm still getting this error. I made my apex class global ...
5
votes
0answers
45 views

how to access patch version in Salesforce managed package post install script

We have been trying to access the salesforce patch version from post install script part of our managed package. System.requestVersion().patch() always returns null. It's mentioned in the SF ...
5
votes
0answers
176 views

Possible to create a generic “invocable class” per object?

My organization is starting to feel some pain around using Process Builder + Flow (error handling mostly, but also inherent Flow inefficiencies and the inability to run Flow in system context). Thus, ...
5
votes
0answers
80 views

record.clone().clone() instead of .clone()?

We are using Andrew Fawcett's SObjectDataloader Library where I fixed a couple things and stumbled over odd behavior that I couldn't find valid explanation for. So in the Library, records are ...
5
votes
0answers
327 views

How to run a macro using apex class?

How can I run a macro using apex class? I have used a Visualforce Page to run the macro with standard method "sforce.console.runmacro" in javascript. Similarly, I need to call it in an apex class ...
5
votes
0answers
376 views

How do you use a mock response when calling Auth.JWTBearerTokenExchange.getAccessToken()?

Let's say I have a class like this /** * Example of using JWTBearerTokenExchange to demonstrate issues with testing and mocks */ public class JwtBearerTokenExample { public static String ...
5
votes
0answers
169 views

Working with Very Large SOQL Queries

Background This is a question about your experiences managing huge amount of data for UIs. With an ERD like this, where the arrow directions reflect the fields lookup directions. (e.g. entity "B" ...
5
votes
0answers
251 views

Hitting error when trying to save HTML5 canvas in VisualForce Page

We have a requirement to open an image attachment in a VisualForce page, the user should be able to draw on the image and those edits should be updated in the attachment on save. So to achieve this, ...
5
votes
0answers
221 views

Dynamic trigger creation from managed package

I have a requirement to create triggers dynamically after a managed package is installed. I have read that the tooling API can be used to create triggers dynamically however it cannot be used in ...
5
votes
0answers
502 views

Site.getBaseUrl returns empty string in test method

I'm writing tests for the community site controller class and I've faced with some problem. When I invoke a controller method that includes Site.getBaseUrl() from test method I get an empty string. I ...
5
votes
0answers
219 views

question on crontrigger and possible state values

Whenever a scheduled Apex Job is submitted, an entry is made in the CronTrigger table. What I see is, when this job is completed successfully, I see the State changed to "DELETED". Based on the SOAP ...
5
votes
0answers
367 views

How do I create a User without asking them to set their password?

I'm developing a new integration between SFDC and an external system. Almost everything is working fine, but I'm facing some issues when creating a new user. For now, the main problem is when I ...
5
votes
0answers
143 views

Postinstallscript fails to insert child records

I have a post install script that executes after the package has been installed and it worked perfectly. But recently it had to be changed to include some dummy data as an example. So I added the code ...
5
votes
0answers
580 views

Append content to a document

I need to create a huge document. Naturally I face up the apex's limits such that heap size and string length. I can split the creation of the document using a batch job. I thought to create the rows ...
5
votes
0answers
646 views

Amazon SES Sending email with attachments

I am trying to send emails for salesforce with attachments HttpRequest httpReq = new HttpRequest(); httpReq.setMethod('POST'); httpReq.setEndpoint('https://email.us-east-1.amazonaws.com');...
5
votes
0answers
2k views

error from test method - “apex job is already scheduled for execution”

I have a batch apex which starts itself after x mins. this is done in finish() method using , system.scheduleBatch() method. below is how the batch looks like, global class my_ProcessPurge_Batch ...
5
votes
0answers
258 views

JSON.serialize alternative which support more objects like HttpRequest or Schema Describes

Often I need a easy and robust way to convert huge nested data structures into an string. Mostly for dumps, logs and debug. JSON.serializePretty() comes close but does not support all Object types ...
4
votes
0answers
175 views

Sync with Pardot by Apex Trigger | Duplicate send to Pardot button in Apex

I have Pardot installed in my SF sandbox and it is connected to a Pardot Sandbox. [Use Case]: If a prospect is in the recycle bin in Pardot, then it does not sync with Salesforce. If from a ...
4
votes
0answers
42 views

Visualforce page not displaying correct Devnagiri words when it render as pdf

I am using Arial Unicode MS font in the visual force page. I need to render it as pdf. The HTML contains Devanagari words. HTML is displayed properly but the words are broken in the generated pdf. e.g ...