Skip to main content
New
Stack Overflow Jobs powered by Indeed: A job site that puts thousands of tech jobs at your fingertips (U.S. only). Search jobs

Questions tagged [constructor]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1 vote
1 answer
142 views

Adding event listeners in the Constructor of LWC

Generally, In Lightning Web Components (LWC), you should not manipulate the DOM or add event listeners in the constructor. The constructor is called when an instance of the component is created, but ...
Rahul Allada's user avatar
-3 votes
1 answer
92 views

Line: 4, Column: 23 Invalid constructor syntax, name=value pairs can only be used for SObjects: Contact

Line: 4, Column: 23 Invalid constructor syntax, name=value pairs can only be used for SObjects: Contact List<Contact> conList = new List<Contact>(); // here is Empty List for Contact ...
rajesh hyalinge's user avatar
0 votes
1 answer
127 views

Apex Test - setSelected() is empty!

Hi I'm having an issue with a non-static test method which is passed a list of records from the standardSetController. I've called setSelected() and an instance of the non-static method but when I'm ...
plateaued1's user avatar
0 votes
1 answer
129 views

Apex Test - Constructor Not Defined

Hi I'm having some issues with a test class which is calling a non-static method. I have looked at some previously asked question but I don't fully understand how to structure the calling of the class....
plateaued1's user avatar
1 vote
1 answer
271 views

Gack Error Id : 2020409769-104966 (551437190) when there is no constructor without parameters

When a Lightning Action is called from LWC and a DTO model instance is passed, where the corresponding DTO Model class doesn't have no arguments constructor, an internal error is shown: Gack Error Id ...
Patlatus's user avatar
  • 17k
0 votes
0 answers
772 views

System Assert Initial List Size

I have a class that has a constructor that is defining a list. I want to assert that the initial size of the list is set properly. An error is being throw when I run my test class around verifying the ...
Olivia's user avatar
  • 3,461
0 votes
1 answer
75 views

Should I be using a better OOP pattern (DI, Factory?) for this API callout with a big wrapper class

I'm trying to up my OOP game and utilize good patterns where I can. Recently I wrote some classes that essentially take a custom object (a quote) and build a very long/complex api request body using a ...
Carryonplease's user avatar
1 vote
1 answer
1k views

What is host element in constructor hook in lwc lifecycle mean?

On the lwc lifecycle hook the documentation reads The constructor() method fires when a component instance is created. Don’t add attributes to the host element during construction. You can add ...
Gargi Gupta's user avatar
0 votes
0 answers
1k views

Call method with String return in another class

I'm trying to get required information (currentCompany()) via method: public without sharing class RemoveUserInfo implements Queueable { private List<User> users; private List<Account&...
Thomas McKiny's user avatar
0 votes
1 answer
2k views

Error during LWC component connect phase: [Maximum call stack size exceeded]

I am trying to assign value to a property of my parent component's constructor method. Below is the html code: <template> {welcomes} <c-testfile></c-testfile> </template&...
Pratikshya Satapathy's user avatar
0 votes
1 answer
631 views

LWC constructor and wire adapter

Already wire adapter was there in LWC i.e. @wire annotation to display the records,so can we do the same thing (display the records) through LWC constructor also? If yes, then why @wire feature was ...
SFDCTashan's user avatar
2 votes
1 answer
269 views

Constructor chaining giving method not defined

I have the following class with constructor chaining , but the validations are returning Method not found or incorrect signature class @IsTest global class CalloutMock implements HttpCalloutMock { ...
Akash Jain's user avatar
3 votes
1 answer
2k views

How can I export an LWC function that's declared within a constructor?

I have a function that is declared within my default class (constructor) that I would like to export to a Jest test suite. Is this possible? testLWC.js import { LightningElement } from 'lwc'; export ...
JMRiss's user avatar
  • 45
0 votes
1 answer
2k views

How to use Wrapper Class in constructor and call it in Queueable?

My Queueable Apex class worked fine before but after discovering Apex PMD ruleset, found that using >4 parameters in any method or constructor is not best practice. I tried searching up answers ...
compski's user avatar
  • 1,352
-2 votes
1 answer
150 views

i need a little help ): with constructors in apex class

public class OrderItemWrapper{ @AuraEnabled public string orderItemName; @AuraEnabled public decimal orderItemQuantity; @AuraEnabled public decimal orderItemAvailableQuantity; @...
Francisco Javier Ortiz Arguell's user avatar
1 vote
1 answer
408 views

Cannot call class from within another class

I have two classes. Inside class B, I want to use the method written in the class A. And I dont know why I get error. Class A look like this: public class ZipCodeUpdateOwnerships { //This ...
Felix Fong's user avatar
0 votes
1 answer
718 views

Can @future be called in constructor of a class

Trailhead Link - https://trailhead.salesforce.com/content/learn/modules/asynchronous_apex/async_apex_future_methods#:~:text=Future%20methods%20won't%20necessarily,same%20order%20they%20are%20called.&...
Pankaj Kumar's user avatar
1 vote
1 answer
666 views

Code coverage for constructor

Apex class: public with sharing class PractitionerQTriggerHandler extends Domain{ /** * Constructor * @param records List of Records */ public ...
Frank's user avatar
  • 423
1 vote
1 answer
168 views

why Soql have to be inside constructor

hi I'm new to salesforce. I have a basic question hope you guys can help me. I'm doing "Display a SOQL query on a Visualforce page" but throughout all the information i found query have to ...
user97366's user avatar
1 vote
1 answer
2k views

Any risk in recompiling all Apex classes in org?

Running into an issue with a deployment, getting a ton of errors of the following flavor: line -1, column -1: Dependent class is invalid and needs recompilation: Class MeansRegisterCustomerTest : ...
Aavo Reinvald's user avatar
1 vote
1 answer
111 views

Unknown Constructor error for extension controller

Hi im trying to use an extension controller for some kind of calculation in my vs page and getting error about the constructor: Unknown constructor... any help with that? code public with sharing ...
user91488's user avatar
0 votes
1 answer
234 views

Encountering Constructor not defined in test class

I'm scheduling a batchable class that deletes records from a custom object. The test class for my scheduled class saves without errors. However, I'm getting a "Constructor not defined: [...
Patrick Marks's user avatar
1 vote
2 answers
4k views

how to call constructor class method by calling constructor

i want to load wrapper class with one shot, but I couldn't able. may be still my oops skills are weak. i feel we can write much better way public class WrapperA{ public Id sobjerecid; public ...
sdandamud1's user avatar
  • 2,705
0 votes
1 answer
39 views

Constructor not defined error - error after setting date fields as null during object creation

I have created a wrapper class to create an Object and send it as a request to a third party system. It was working well. But after I added a two new arguments of the Datatype Date, I am getting the ...
Akshay Vasu's user avatar
1 vote
1 answer
390 views

Unknown constructor issue

I have an apex class for which i get error: uknown constructor the code: public with sharing class SendDocumentCont{ public String .... public SendDocumentCont(ApexPages.StandardController c) what ...
Christos's user avatar
0 votes
1 answer
1k views

APEX - Initialize sub classes in a constructor

I am trying to find a solution to initialize a subclass in a constructor, but I have the following error message : Variable does not exit: Info public class Products { public String Name; ...
Vneq's user avatar
  • 79
0 votes
2 answers
230 views

How do I instantiate a list of objects, where each object has 3 data types?

JS developer here. I'm sending a JSON node to my Apex class and it's in the following format: "myNodeName" : [ { "id": "a123", "foo": true, ...
JMRiss's user avatar
  • 45
0 votes
1 answer
679 views

Writing test class for constructor

like title says ,I'm trying to write a test class for the following constructor , but I'm getting Constructor not defined error. My method is : public class AccountPlanSumLightningController { public ...
Dead_end_Developer's user avatar
0 votes
1 answer
640 views

Use invocable method on the MergeCaseController, error that i will not be able to use the invocable method on a constructor. thank you

I am trying to use the invocable method on Public MergeCaseController(ApexPages.StandardsetController controller) so that i can call this from a flow.. But i am having issues doing so, public ...
Jerica Lean's user avatar
0 votes
1 answer
763 views

How do I call this method inside of inner class

Hello im really confused about how to call requestBody(Id quoteId) inside this code I created using inner classes: public class PT_Interface{ public class Request_Model { public ...
Lavasocks's user avatar
0 votes
1 answer
175 views

How to properly construct a callout

I'm trying to setup a callout class to properly handle the passing in of a few variables to build an endpoint string. As you can see below I'm struggling with how and where to declare certain ...
weytani's user avatar
  • 397
-1 votes
1 answer
48 views

Constructor not defined: [PbxmlGroupConnection].<Constructor>(DataSource.ConnectionParams)

global class PbxmlGroupProvider extends DataSource.Provider { override global List<DataSource.AuthenticationCapability> getAuthenticationCapabilities() { List<DataSource....
sanketmane's user avatar
0 votes
1 answer
70 views

List is not constructed in memory until I print it

I'm confident that I'm missing something here. I'm not able to evaluate a list of Ids until I print it using System.debug. In the snippet below, I take a list of Accounts and extract the Ids from ...
blastocyst.jones's user avatar
0 votes
2 answers
3k views

How to define a constructor and pass parameters to schedulable controller [duplicate]

I have a situation where I need to pass a string to schedulable controller from batch or any apex controller. I see that we can do it using public constructor in schedulable implementation. Please let ...
AshSFcloud's user avatar
3 votes
1 answer
7k views

LWC constructor() error: "Must call super constructor in derived class before accessing 'this' or returning from derived constructor"

I'm getting the following error: Must call super constructor in derived class before accessing 'this' or returning from derived constructor after adding a very simple test constructor to my LWC ...
Brent Bowers's user avatar
  • 3,134
0 votes
1 answer
4k views

Constructor Syntax in Batch Class

I'm new to the development side with no real development background in any language. So I wrote this batch class, and I can't quite figure out how to implement the proper syntax for the constructor. ...
Sean AB's user avatar
0 votes
1 answer
312 views

Variable remains empty after initialization

Simple Apex (Java actually) question, after I initialized the variable 'a' in a constructor, I tried to access it with a different method but it remains null. Class FirstClass{ String a; ...
Json's user avatar
  • 1,617
-1 votes
1 answer
77 views

Initializing an instance variable

What are the benefits of initializing an instance variable in an instance block rather than constructor of the class?
Faiz's user avatar
  • 31
2 votes
1 answer
287 views

How to disable constructors in custom exceptions?

There is a lot out there on how you can't override exception constructors and how to do custom exceptions, but I haven't been able to find anything on disabling a constructor for an extended class. I'...
Kamurai's user avatar
  • 73
-1 votes
1 answer
810 views

Create a constructor for an outer class with inner classes that have constructors?

What would a constructor for the outer class of the following look like? public class outerClass { public Data data {get;set;} public class Attributes { public String symbol {get;...
vshake's user avatar
  • 99
0 votes
1 answer
1k views

Batch Test class Constructor Not Defined problem [duplicate]

I have the following problem in a test class. Constructor not defined: [Soma_Dependentes_Update].<Constructor>() Test class of the batch process: @isTest public class ...
Juliano Szlachta's user avatar
0 votes
1 answer
481 views

Constructor not defined error on Event trigger

I'm fairly new to development but I'm currently trying to move some triggers into classes to follow the one trigger per object design pattern. I'm getting the following error in the trigger: ...
J. Rodden's user avatar
0 votes
1 answer
725 views

Constructor not defined executeBatch trigger to pass ID to batch class

Ok...trying to write my first class and trigger and running into a wall that I can't seem to get over on my own. Use case: on a custom object called manufacturer__c, when a field goes to "in Process" ...
Bobbo's user avatar
  • 11
3 votes
1 answer
4k views

Call Parametrized constructor using Type.newInstance()?

I am designing a solution where it should be flexible to add handlers using configuration. So I am saving the handler class name in the custom metadata record and then would be instantiating it using ...
Pranay Jaiswal's user avatar
3 votes
1 answer
6k views

Return null instance when constructor parameter is null

So I want to have some sort of condition like this: public Foo( Id baz ){ if(baz == null){ return null; } else { this.entry.baz = baz; } } ...
dzh's user avatar
  • 4,125
-2 votes
1 answer
2k views

String value from constructor to Apex methods

I have set a value to a static string variable in constructor and while I try to access that value in my apex methods , I always receives as NULL. public class Mycontroller { public static string ...
Quddus's user avatar
  • 177
0 votes
3 answers
2k views

Use Type class to call parameterized constructor

Using this to get below working: public class t12345 implements Database.Batchable<sObject> { String query; Boolean xyz; public t12345(String query){ ...
sf_user's user avatar
  • 2,250
0 votes
1 answer
24 views

(re)Scheduled class with count. Initialized to 0, increased to 2. Don't understand why

I have a schedulable class that will be rescheduled again. This class contains a count. Here is how it is supposed to work constructor set count to 0 a run method increase count then test condition ...
Guillaume's user avatar
  • 115
2 votes
1 answer
2k views

Setting field value in sObject constructor vs after instantiation

My question: Why can you set a value of a field like ParentId on the CaseTeamTemplateRecord object in the constructor during instantiation, but receive an exception if you set the value after ...
Bob Lopez's user avatar
  • 1,471
0 votes
1 answer
1k views

how to call the constructor of the apex controller in the test class

Below is my controller class. Public class VMSalesOrderUserEditpage{ public list<VM_Sales_Order__c> vmList{get;set;} public VM_Sales_Order__c VMSOrd {get;set;} public string vmId {get;set;} ...
user avatar