Questions tagged [inner-class]

An inner class or nested class is a class declared entirely within the body of another class or interface. It is distinguished from a subclass.

Filter by
Sorted by
Tagged with
2 votes
1 answer
64 views

Inner Class Without Sharing not working as expected

I found this post (Sharing rules and Inner classes), which references documentation that inner classes do not inherit the sharing of their container class. From the documentation: Both inner classes ...
user avatar
1 vote
1 answer
249 views

Inner class does not allow maps

I am working through a use case where I have a text field and a lookup field. I want to populate the lookup with the Id of the record that matches the name of the text field. After I query the lookup ...
user avatar
  • 3,351
0 votes
1 answer
195 views

Pass object of custom class as parameter to another class

I want to make something like in the code below, but it didnt work. Erorr: Method does not exist or incorrect signature: void method1() from the type SObject. public with sharing class Test1{ ...
user avatar
0 votes
1 answer
149 views

How do I call inner classes from execute anonymous or another class

When I try to call this from execute anonymous it fails and says "Type is not visible: OutterClass.InnerClass " OutterClass.InnerClass inresponse = new OutterClass.InnerClass(); System.debug(...
user avatar
2 votes
1 answer
122 views

Apex @RestResource returning result inner class exposes private attributes

Any simple @RestResource may return results in the form of an instance of an inner class. I expect any private attribute of the inner class to stay exposed only to the inner class, thus not be ...
user avatar
2 votes
1 answer
29 views

Recommended explicit sharing declaration for inner classes

In our last Salesforce Security Review we have faced an issue related to the ommitted sharing declarations of inner classes acting as a wrapper. We have passed this review for years so I guess some ...
user avatar
0 votes
1 answer
4k views

Wrapper class showing error 'Inner types are not allowed to have inner types' in apex

I am trying to create a wrapper class to hold the JSON response in my apex class. But I am getting the error ' Inner types are not allowed to have inner types '. Below is my wrapper class. public ...
user avatar
0 votes
1 answer
405 views

Variable to hold the return of type wrapper class from a method

I have a class and a method. In the method I am calling another method of another class - Class2.Method2 The return type of method 2 is a wrapper class. What should be the variable type in my method 1 ...
user avatar
1 vote
0 answers
46 views

Complex type passed by aura component to apex method

we have this inner class: public class Documents { @AuraEnabled public String type; @AuraEnabled public List<Custom_Document__c> documents; } And we use it in a method declared like ...
user avatar
  • 1,439
0 votes
1 answer
241 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 ...
user avatar
5 votes
2 answers
418 views

An inner interface inside an outer interface is not supported in Apex?

Can't find a post saying this, and I get a compile error, but just to be sure, this is not supported in Apex right? public interface Access { public interface Context { ... } ...
user avatar
  • 130k
0 votes
1 answer
226 views

How to make a Json object a subclass

I have a Json Object which I created with the online JSON to apex tool. This works a a separate class how can i make this a subclass. I get the error: Inner types are not allowed to have inner ...
user avatar
  • 2,102
1 vote
2 answers
2k views

Populate Apex Inner Class Variables in Lightning Web Component

Need a help in Lightning Web Components. I am working on an assignment where I need to get some values from the UI, populate it on an inner class variables defined in an Apex class and then make a web ...
user avatar
3 votes
2 answers
3k views

Best Practice deserialize a JSON to avoid heap size limit

I'm sending an HTTP request to get a JSON of Students. The JSON is a complex JSON with arrays and its break into 3 objects in Salesforce. I'm using a class (JSON2APEX) to deserialize the JSON. Some ...
user avatar
  • 963
8 votes
1 answer
404 views

Managed package patches - can a public inner class be added?

In the Create and Upload Patches documentation, there is no mention of restrictions on adding inner classes to an already packaged top-level class. The restrictions listed are: You can’t add package ...
user avatar
  • 130k
5 votes
1 answer
388 views

Inherited sharing question in nested inner classes

The sharing documentation Using the with sharing, without sharing, and inherited sharing Keywords says: The sharing setting of the class where the method is defined is applied, not of the class where ...
user avatar
  • 130k
1 vote
1 answer
204 views

Sending Inner class as a param from Queueable apex to a batch

I have a queueable apex that calls to a batch. Inside the queueable class - I have inner Class that writes a log with incorrect fields. The Inner Class inside the queueable class : public class ...
user avatar
  • 963
0 votes
1 answer
91 views

Complex JSON Parsing - Beware

Not for the faint of heart. Trying to do a Scalyr integration, and wrestling with some pretty difficult JSON. I have used JSON2Apex which generated several inner classes, and the Apex and JSON are ...
user avatar
  • 648
0 votes
1 answer
301 views

Deserialization using Apex class generated using JSON2Apex gives null for inner values

I have the following piece of code. @RestResource(urlMapping='/Update') global with sharing class OpportunityUpdate { @HttpPost global static void updateOpportunity() { RestRequest req = ...
user avatar
  • 1,093
0 votes
1 answer
340 views

LWC: Error accessing Inner class from javascript

Im running into the following javascript error when trying to display inner class data on my LWC. This was working fine until I added ".data" to my output variables for employerAddress to resolve ...
user avatar
1 vote
1 answer
2k views

LWC inner class property access issue

Im receiving the following error when trying to initialize the OnboardingPeopleResult class from a button on my LWC form. This data object initializes an inner class OnboardingAddressResult as one if ...
user avatar
1 vote
1 answer
709 views

How to test an inner class?

I did my research, but could not find a clear guidelines on how to test an inner class. This is my inner class: public class ExistingAccountResult{ public String salesforceaccountid {get;set;} ...
user avatar
  • 337
0 votes
1 answer
215 views

Invalid type when creating a map of <string, list<innerclassobject>>

Invalid type: EcPerformanceRecordList I want to create a Map of userid and list of sObject records, then loop through this map so that I can count how many apps have been submitted per user....
user avatar
1 vote
1 answer
306 views

Clone a map containing an inner class so it passes by value and not reference?

I have a map<string, InnerClass>, where the inner apex class containing no sObjects, just a bunch of simple variable types like booleans, integers and strings. (It also contains another inner ...
user avatar
  • 3,472
4 votes
3 answers
824 views

Adding a Wrapper Class to an External Class

I am confused about what is happening in a small section of some code. I have a class that has a wrapper class inside it. There is an external class that calls this wrapper class Models.add(new ...
user avatar
  • 3,179
3 votes
1 answer
2k views

How to use inner class / wrapper class as scope in Apex Batch

I already successfully collecting the list of data from callout another system as json body to the inner class to accomodate custom information: Here is the apex class of the inner class: public ...
user avatar
  • 487
3 votes
1 answer
2k views

Inner Classes/Interfaces

the guide says that one difference between Java and Apex is: Inner classes and interfaces can only be declared one level deep inside an outer class. Considering I know in Java what is an Inner class,...
user avatar
3 votes
1 answer
348 views

apex: Innerclass not not available in map in outside class

I have the following setup: public with sharing class MyOuterClass extends BaseClass { public class MyInnerClass { public Id classId {get; private set;} public MyInnerClass() {} ...
user avatar
0 votes
0 answers
66 views

Why do we need inner classes? [duplicate]

Can anyone give me an example when an inner class is used. I started with wrapper class and found inner class is used in that but as i am all new to this i was thinking if anyone can give me an ...
user avatar
  • 125
0 votes
0 answers
40 views

Parsing the following JSON response

I need to parse the PRIM_CITYAC,PRIM_STATEAC,PRIM_COUNTRY_NMAC from the following response. I'm very new to REST API. I've create inner class with list in order to obtain the values. Now i got those ...
user avatar
0 votes
1 answer
851 views

how to intialize array for inner class and assign mulitple values to that class?

I have developed vf page which have page block table displaying 3 fields. I tried to modify it with use of apex :repeat so that i have created one inner class as public class outer{ public ...
user avatar
  • 35
12 votes
2 answers
2k views

Confirmation that (inner) classes are still not fully supported in @AuraEnabled methods?

When writing a controller for a Lightning Component, it is convenient to add the data transfer object classes as inner classes of the controller. This works fine for sending data to the client but I ...
user avatar
  • 130k
2 votes
1 answer
3k views

Nested Inner Classes creation in an apex class

Below is the structure am trying to build. Its throwing Error: Compile Error: unexpected token: 'class' public class maincls { public class test1 { public String teststr {get; set;...
user avatar
  • 2,146
0 votes
2 answers
2k views

How to increment a integer value in wrapper class

i have a scenario, i want to increment a value in wrapper class let's take testWrapper class is there , having a Integer variable called incrementX For ex 5 records are there , 1st Recorde --> ...
user avatar
8 votes
1 answer
632 views

Problem using Protected modifier to expose method to inner class

I have a use case where I will have an Apex Class wrapping an sObject, and I need to be able to swap out certain internal functionality based on certain conditions. My plan is to use an few inner ...
user avatar
3 votes
1 answer
881 views

Instance method clashes with static method

I am working with Apex inner classes and I got the limitation described below I can't name a method in my inner class with the same name I used in a static method in the containing class When I do ...
user avatar
  • 2,387
0 votes
1 answer
30 views

Error in page controller [closed]

I'm new to APEX, so I'm going through the workbook. Got to the page about 'Using Inner Classes in an APEX Controller'. As far as I can tell, the code I've written replicates what the tutorial has ...
user avatar
0 votes
1 answer
44 views

how to retrive list from inner class

class code: public list<innerclass> inclass= new list<innerclass>(); public class innerclass { public string accountid{get; set;} public string accountname{get; set;} ...
user avatar
  • 13
3 votes
2 answers
6k views

For loop within for loop

I have a custom object record with a start date, an end date, and a amount field. I want to be able to take the difference between the two dates in number of months, divide the amount by the ...
user avatar
  • 3,351
4 votes
1 answer
1k views

Code Coverage on Inner Class/Variable Declarations

When we use an inner class, fields will not be covered unless otherwise we declare them with {get;set;}(even though they are accessible from the test class) Also these lines are not get counted as to ...
user avatar
  • 6,161
10 votes
2 answers
13k views

Purpose of an inner class

I've read in the Apex Workbook and the Apex Developer Guide the mention of inner classes. What is their purpose? I see in the Apex Workbook that they used private variables and setter/getter methods ...
user avatar
  • 2,708
0 votes
1 answer
329 views

how to assign data from Inner class to out class

i have succesfully parse my JSON data. but now i want data back from following APEX method "getCustomerData()" like below: DxModel[id=2, email=asd@GMAIL.COM, first_name=clerk, last_name=dx, ...
user avatar
  • 119
6 votes
1 answer
2k views

Possible to declare static constants in an inner class?

I want to define an outer class with two inner classes, the inner classes containing specific constants related to each of them. For example: public class Stuff{ public class Letters{ ...
user avatar
3 votes
1 answer
569 views

Implementing CompareTo In An Inner Class That Needs Outer Class Data

I'm using Apex and VisualForce to make an "open house event check-in page" for a department. For various reasons pertaining to AppExchange plugin compatibility, we are storing a separate "Event" ...
user avatar
  • 1,139
2 votes
1 answer
579 views

Why Don't Visualforce Wrapper Class Getter/Setter Methods Not Exist?

I have a wrapper/inner class like so: public class parameter{ public String source { get; set; } public Integer year { get; set; } public String field { get; set; } public parameter(...
user avatar
  • 4,368
15 votes
3 answers
2k views

What's It Called: Inner Class Without Sharing?

I believe I have heard a specific term for this pattern, but I am not able to retrieve it from the foggy banks of my memory: public with sharing class OuterClass { public without sharing class ...
user avatar
  • 143k
10 votes
1 answer
980 views

Why are static variables allowed only in outer classes?

According to the documentation, static variables are allowed only in outer classes. Why is that? Is it because you'd need to instantiate the inner class first?
user avatar