Skip to main content

Questions tagged [compile-error]

Compilation error refers to a state when a compiler fails to compile a piece of computer program source code, either due to errors in the code, or, more unusually, due to errors in the compiler itself. A compilation error message often helps programmers debugging the source code for possible errors.

Filter by
Sorted by
Tagged with
14 votes
3 answers
12k views

Call to another constructor must be the first statement in constructor block

I am confused why the following pattern's call to the other constructor block does not count as the first statement in the constructor block: public class MyClass { final String someProperty; ...
Adrian Larson's user avatar
  • 150k
12 votes
1 answer
349 views

Why is CaseFeed.CreatedById Polymorphic?

A polymorphic lookup is, by definition, one where the SObjectType of the parent be multiple different values. That was the basis for how I compiled Polymorphic keys - definitive list? However, a ...
Adrian Larson's user avatar
  • 150k
11 votes
3 answers
4k views

Why is Map<Id, Set<Id>> an unsupported parameter type in future methods?

I am trying to create some junction records via callout (in this case, SkillUser records). Since I am doing so from a trigger, I need to use a @future annotated method. The Apex Developer Guide states ...
Adrian Larson's user avatar
  • 150k
10 votes
2 answers
1k views

Unfamiliar Syntax

I came across the following code online: @future(callout=true) public static void runWarehouseEquipmentSync(){ Http http = new Http(); HttpRequest request = new HttpRequest(); request....
Gabriel Rivera's user avatar
10 votes
2 answers
12k views

What is the best way to cast/convert Map<String, SObject> to Map<Object, Object> and back again?

To reduce code duplication, at the risk of type safety, I have some method: public Map<Object, Object> doSomething(Map<Object, Object> inputMap) { Map<Object, Object> outputMap; ...
Brian Kessler's user avatar
9 votes
1 answer
24k views

Checking if element is in a Set

I wrote a method last night that creates a new custom object record that is related to an Account and a User. it works great however, it breaks when there is an already existing record for a user. ...
Dan Wooding's user avatar
  • 3,612
9 votes
2 answers
900 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 { ...
Mikhail Ivanov's user avatar
8 votes
2 answers
3k views

Is there an Apex code formatting standard?

Are there any documents out there that talk about proper formatting in apex? I have not been able to find too much on this subject (maybe my google skills are weak). Some examples: //comment with ...
Tyager's user avatar
  • 574
8 votes
1 answer
12k views

Method does not exist or incorrect signature: void contains(String) from the type List<String>

I cannot figure out why the following code (which is within a Test Data Factory class) would cause this error when validating in Production for deploy: Method does not exist or incorrect signature: ...
Mike's user avatar
  • 1,199
8 votes
1 answer
370 views

Syntactic vs Performance difference on object creation?

Is there any performance difference between: Contact con = new Contact(); con.Id = conId; con.AccountRoles__c = newRole; ... and... Contact con = new Contact( Id = conId, ...
Nathan Williams's user avatar
7 votes
1 answer
65k views

Static method cannot be referenced from a non static context: List<String>

I believe this is a basic query and am missing something out. However am exasperated finding an answer to the issue and thus seek your guidance. The intent is to create a static method ...
max steel's user avatar
7 votes
2 answers
7k views

Cannot Return a List of Strings - Void method must not return a value

I've been using the notes from Simple Apex class to return a list of strings. I am having trouble getting this code to work. I'm writing a simple Apex Class as part of the Trailhead module Getting ...
Samuel's user avatar
  • 83
7 votes
1 answer
9k views

Variable not visible

When I try to save the code (API version 43), I keep getting a compile error stating: Error: Compile Error: Variable is not visible: testClass.XYZ at line 5 Here is the class: global with sharing ...
Kalyan's user avatar
  • 73
7 votes
2 answers
974 views

Syntax guide for working with Salesforce Web Components

I am struggling to find any syntax documentation related to building a Web Component, and could really use some help. For example, in my JS file I make a call to a custom APEX api that returns a ...
BlondeSwan's user avatar
  • 1,098
7 votes
1 answer
1k views

Class <classname> : Expression is too long, please split this expression into multiple statements

I have never seen this error before. It comes up when trying to run a test in Production. It happens when promoting the class (with just some capitalization changed, so it's not a real change) to ...
DavidSchach's user avatar
  • 5,926
7 votes
1 answer
217 views

Got syntax error in an Apex class but compiled successfully. Any thoughts please?

In eclipse one of my Apex class showing syntax error on a particular line of code. But it compiled successfully without any issues. Any thoughts on why i am getting this error? Please see the error ...
Bforce's user avatar
  • 6,828
6 votes
1 answer
337 views

Any way to qualify a custom class to distinguish it from a property?

This problem comes up when you try to remove clutter from names because Apex is case insensitive so xyz and Xyz are not distinguishable: public class Xyz { ... private static Xyz[] query(...) ...
Keith C's user avatar
  • 136k
6 votes
1 answer
236 views

JSON.deserialize() for User records wont work

I'm trying to deserialize a received user record on a JSON format. TO achieve this I'm using JSON.deserialize() but when I specify the User class the compiler throws the following error: Save Error:...
Ismael Slimane's user avatar
6 votes
1 answer
3k views

Exact equality operators only allowed for reference types: String

Please find below piece of code where I am getting this error. Error: Compile Error: Exact equality operators only allowed for reference types: String Code: if(((inc.Status_abv__c!=='New') || ...
Testing_SFDC's user avatar
  • 2,950
5 votes
3 answers
4k views

Cannot Assign Private Variable In Test Class

I have an issue, I want to test this line of code: if(compareAnIssue!=null){ The variable in my controller is: private DataToCompare compareAnIssue ; and the DataToCompare type is a public class ...
Amiga 500's user avatar
  • 135
5 votes
1 answer
2k views

Illegal assignment from List<Location> to List<System.Location>

Here's the SOQL I'm trying to run in my anonymous window, against the standard object: List<Location> locs = [SELECT Id, Name FROM Location LIMIT 2]; for(Location l : locs) { System.debug(l....
bkwdesign's user avatar
  • 599
5 votes
2 answers
11k views

Map<Object, List<SObject>> cannot be cast to Map<String, List<Account>>

I'm trying to cast a Map<Object, List<SObject>> to Map<String, List<Account>>, which fails with the error Incompatible types since an instance of Map<Object,SObject> ...
ipavlic's user avatar
  • 3,736
5 votes
2 answers
564 views

"Entity is not api accessible" vs. "Variable does not exist"

I've seen this error before many times, occasionally even in my own code. Entity is not api accessible It seems like often the compiler thinks you're looking for a standard object and it can't ...
Adrian Larson's user avatar
  • 150k
5 votes
2 answers
312 views

When (if ever) will testmethod fail to compile?

I just recently learned from the Apex Developer Guide documentation on the IsTest Annotation: The testMethod keyword is now deprecated. Use the @isTest annotation on classes and methods instead. ...
Adrian Larson's user avatar
  • 150k
4 votes
1 answer
5k views

DML requires SObject or SObject list type error

I got some advice a couple days ago to improve my batch updater class. I have been working on it but am getting a compile error. I get the error: DML requires SObject or SOBject list type: Map Line ...
Dan Wooding's user avatar
  • 3,612
4 votes
2 answers
5k views

Lightning Web Component (LWC) Class Definition Syntax

Lightning Web Components (LWC) are made up of multiple files in a bundle. For this question I am focusing on the component's main .js file where the web component js class is implemented. Example code:...
sskular's user avatar
  • 583
4 votes
2 answers
372 views

Rollback Block?

I am curious what kind of syntax is Apex method System.runAs(){ } where in curly brackets I can run my code which will be executed as passed user. I would like to write my own method with that syntax ...
patryk's user avatar
  • 655
4 votes
2 answers
323 views

how do I call this method with list as an argument from another class?

Below is the name of my method and argument of that method private static void Callout(List<Id>cnt) I am calling above method using following code classname.Callout(cnt.id). //where cnt is ...
Aman's user avatar
  • 159
4 votes
2 answers
2k views

Compile error: Variable Does not exist while attempting JSON deserialize

Not sure if this is a platform bug or by design feature with case insensitive variable names?, but it gave me a lot of trouble so wanted to post a question about it to document the workaround I found. ...
nickforce's user avatar
  • 419
4 votes
1 answer
272 views

SOQL Not Recognizing Field?

I have this apex code: //testing code for above List<Contact> contacts = new List<Contact>(); for (MtgPlanner_CRM__Transaction_Property__c lo : [SELECT MtgPlanner_CRM__Borrower_Name__c, ...
Peabrain's user avatar
  • 215
4 votes
1 answer
16k views

DML requires SObject or SObject list type: List<List<Commission_Line__c>>

How do I insert the values from the map? I want to insert the grandchildren records in variable Commlinesmap, but I get this error: DML requires SObject or SObject list type: List> Error is at ...
Sammy's user avatar
  • 337
4 votes
1 answer
899 views

Not being able to access Flow variable in Apex class

I am trying to create a flow which creates an account record and then navigates to the newly created record detail page VF Code <apex:page Controller="AccFlowController" TabStyle="Account"> &...
Madhurima's user avatar
  • 1,425
4 votes
1 answer
4k views

Invalid field RecordTypeId for SObject Case

This evening I finally started working on an Apex Specialist Superbadge. I followed all the steps to prepare the developer org and started coding, however, I can't compile my code due to this weird ...
smukov's user avatar
  • 5,603
4 votes
1 answer
232 views

Newbie - First Apex Class question re: No viable alternative character

I'm doing one of the Trails, converting my .NET and Java knowledge over. I'm stumped on a really simple task. Objective: Return a list of accounts where the BillingState is the same as the state ...
Driss Zouak's user avatar
4 votes
1 answer
208 views

Are RecordType Static Resources not Allowed in Apex?

I get the following error when I try to save a test class with List<sObject> recordTypes = Test.loadData(RecordType.sObjectType, 'Record_Types'); "Method does not exist or incorrect signature: ...
Gabriel Rivera's user avatar
4 votes
1 answer
546 views

Numeric input on VF page linked to value of a Map in controller

For one of the requirements I'm building a visualforce page with a controller. The problem is that I can not save the page with <apex:input> type being number. Compilation error is: Expected ...
Novarg's user avatar
  • 5,264
4 votes
1 answer
660 views

Error: Compile Error: expecting a right parentheses, found 'System.runAs' at line 4 column 22

Guys need some help in figuring out where I am going wrong. I am getting the above error at line 3. Any help is appreciated. @isTest private class LabsContactLookupPopupController_Test { public ...
Dinesh KR's user avatar
4 votes
0 answers
497 views

Baffling compile error: "A non foreign key field cannot be referenced in a path expression: ChangeEventHeader"

Why is it that this will not compile: trigger AccountChangeTrigger on AccountChangeEvent (after insert) { String dmlType = Trigger.new[0].ChangeEventHeader.changetype; ... A non foreign key ...
Brent Bowers's user avatar
  • 3,144
4 votes
0 answers
135 views

compiling error during runtime for class that compiles fine

I'm getting the following error (below) while executing a future call. The mentioned class compiles and saves fine upon retesting. Any idea why this would be occurring at runtime? It seems to work ...
Phil B's user avatar
  • 5,026
3 votes
1 answer
8k views

Illegal assignment from Datetime to Date

I am trying to map a custom object's CreatedDate to another custom object's custom date field. But I am getting this error: Illegal assignment from Datetime to Date I am doing something like this:...
slsfrc's user avatar
  • 99
3 votes
1 answer
987 views

Unexpected token Error

I've created a custom button called Commit and I'm trying to call the following method using action = {!.commit}, Apex below Do I need to do anything else to be able to call commit in my VF?
Nikz_Kool's user avatar
3 votes
1 answer
299 views

Dynamic list using ternary if are not accepted by apex

Considering the code snippet: .. List<SObject> lstSObject = sentence == true ? List<typeA__c>() : List<typeB__c>(); Salesforce doesn't explain much as this operator should be ...
Carlos's user avatar
  • 115
3 votes
2 answers
84k views

Method does not exist or incorrect signature: void completeMilestoneDate(List<Case>, List<Case>) from the type CompleteMilesone

I am not getting whats going wrong here ? trigger CaseTrigger on Case (before update) { CompleteMilesone.completeMilestoneDate(Trigger.new, Trigger.old); } and CompleteMilesone public class ...
user avatar
3 votes
1 answer
113 views

Getting a formula validation error, can anybody spot where I am off?

IF ( AND ( ts2__Job__c.Days_Search_Open__c >= 0, ts2__Job__c.Days_Search_Open__c <= 4 ), "0 - 4", IF ( AND ( ts2__Job__c....
jdellamag's user avatar
3 votes
1 answer
4k views

illegal assignment from object to id Error?

I have written following code to insert records on junction object. public static List<PDCN__c> addSelectedPDCNs(List<String> selectedRecords, String groupId) { system.debug('...
Rohit Mishra's user avatar
3 votes
2 answers
5k views

How to Pass in an Array of Strings in a Method Parameter in a Test Class

I'm writing a test class right now, and I'm calling a method in the class that I am wanting to test. The method in the main class that I'm wanting to test is called getTruckerAvailability(). Here is ...
Kruse in Salesforce's user avatar
3 votes
1 answer
827 views

Why does it say 'method does not exist' in my Apex code?

I have a class with this method, which I borrowed from another answer here on Salesforce Stackexchange: public String removeHtml(String stringWithHtml) { String cleanString = ''; if (...
LRK9's user avatar
  • 854
3 votes
2 answers
2k views

Error: Compile Error: unexpected token: public at line 10 column 0

I am a beginner when it comes to Apex and am trying to set up a trigger for Adobe Echo Sign to send a new contract request automatically when a new custom object record is created (something Adobe ...
Richard Ara's user avatar
3 votes
2 answers
2k views

"Variable does not exist" Error While Reference a Package Namespace

Solved? The root cause is my inaccuracy in object initiating: i just forgot to add new. But the misleading error message is still in place. So other APEX devs may hit the same issue. Initial ...
hlopetz's user avatar
  • 247
3 votes
1 answer
168 views

Formula field with several nested functions - can't get right syntax

Trying to create a text formula field that returns certain texts based on combinations of possible values in other fields. Every time I update the syntax, I get an error message either about ...
Aileen's user avatar
  • 31

1
2 3 4 5 6