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.
49
questions
0
votes
1
answer
60
views
My JSON structure gets extra branch when I try to debug
I requirement is to send data from my salesforce org to SAP org. I have successfully written the APEX Class for it. Problem was the JSON structure (see below) was branched and I did not know how to go ...
-1
votes
1
answer
112
views
How to put values (to be JSON serialised) in an inner class which has an array
My requirement is to send data from my salesforce org to an ext org (SAP S4). I have successfully integrated the same by creating an http apex class which sends data from my org to SAP on executing ...
2
votes
1
answer
284
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 ...
1
vote
1
answer
299
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 ...
0
votes
1
answer
936
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{
...
0
votes
1
answer
1k
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(...
2
votes
1
answer
164
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 ...
2
votes
1
answer
45
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 ...
0
votes
1
answer
7k
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 ...
0
votes
1
answer
1k
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 ...
1
vote
0
answers
71
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 ...
0
votes
1
answer
570
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 ...
5
votes
2
answers
588
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 {
...
}
...
0
votes
1
answer
366
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 ...
1
vote
2
answers
3k
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 ...
3
votes
2
answers
7k
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 ...
8
votes
1
answer
535
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 ...
5
votes
1
answer
657
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 ...
1
vote
1
answer
296
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 ...
0
votes
1
answer
115
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 ...
0
votes
1
answer
482
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 = ...
0
votes
1
answer
455
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 ...
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 ...
1
vote
1
answer
2k
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;}
...
0
votes
1
answer
340
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....
1
vote
1
answer
469
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 ...
4
votes
3
answers
1k
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 ...
3
votes
1
answer
3k
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 ...
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,...
3
votes
1
answer
467
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() {}
...
0
votes
0
answers
69
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 ...
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 ...
0
votes
1
answer
987
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 ...
12
votes
2
answers
3k
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 ...
2
votes
1
answer
4k
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;...
0
votes
2
answers
3k
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 --> ...
8
votes
1
answer
775
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 ...
3
votes
1
answer
942
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 ...
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 ...
0
votes
1
answer
46
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;}
...
3
votes
2
answers
8k
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 ...
4
votes
1
answer
2k
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 ...
11
votes
2
answers
17k
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 ...
0
votes
1
answer
377
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=[email protected], first_name=clerk, last_name=dx, ...
6
votes
1
answer
3k
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{
...
3
votes
1
answer
662
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" ...
2
votes
1
answer
592
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(...
15
votes
3
answers
3k
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 ...
10
votes
1
answer
1k
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?