Skip to main content
7 votes
Accepted

Sort List of SObject in Wrapper Class

The confusion is that your class is not really what is termed a wrapper in the Apex community as a wrapper usually decorates a single object instance not a collection. Best drop that suffix from your ...
Keith C's user avatar
  • 136k
7 votes

Does Wrapper Class serve one purpose only?

Looking at what Google has to say, Wrapper is an alternative name for both these patterns: Decorator Adapter So the examples that focus on adding a checkbox might be better labelled as Decorator ...
Keith C's user avatar
  • 136k
7 votes

How to set inner class list as aura attribute?

If I read this right, you want to use an inner class on aura:attribute tag. You cannot (rather should not) use an inner class as an aura attribute, instead you need to handle it differently. If that's ...
Jayant Das's user avatar
  • 30.6k
7 votes
Accepted

LWC JavaScript way to copy List [List A, List B] Values to a single List

Yes. You can use concat: var output = listA.concat(listB); Or you can flatten it: var output = [listA,listB].flat(); Arrays in JS are very robust. You should take time to study their many features ...
sfdcfox's user avatar
  • 491k
6 votes
Accepted

How to insert 3rd level nested records using rest class?

You can create ContactWrapper class which contains standard Contact as a field and list of customers. apex: @RestResource(urlMapping='/Order/*') global with sharing class OrderWebServicesV2 { ...
Ilya Lepesh's user avatar
  • 4,125
6 votes
Accepted

Sorting of two different records referencing their dates

It is possible to write a Comparable wrapper class that can work with various SObject types and fields: public class DateFieldComparable implements Comparable { private SObject sob; private ...
Keith C's user avatar
  • 136k
6 votes
Accepted

Adding a Wrapper Class to an External Class

Somewhere else in the local context, there is a variable declaration that's shadowing the class Models. Example: public class TestQ242685 { public class InnerClass { } public static ...
David Reed's user avatar
  • 92.9k
6 votes
Accepted

Issue with passing class data from apex to javascript in LWC

The attributes in the custom class that you have created should have the AuraEnabled annotation set on them. Then those attributes will be accessible on the javascript side. public class ...
Prudhvi Konda's user avatar
6 votes
Accepted

Access the List<String> in wrapper class to LWC

Javascript is case SEnSiTivE. You have defined variable in apex as monthListBefore but in JS you are trying to access MonthListBefore, which does not exist. So, Try this.MonthList = data[0]....
Rahul Gawale's user avatar
  • 12.2k
5 votes
Accepted

Need to write a Wrapper Class

Unless you're caching the result from the first request to the get; member on the controller every single time the VF page references the { get; member, it'll fire the query contained in the getter ...
Mark Pond's user avatar
  • 23k
5 votes
Accepted

Render Two Lists From Dynamic SOSL?

You need separate tables for each list. Something along the lines of: <apex:pageBlockTable value="{!mySearchWrapper.accounts}" var="account"> <!-- columns --> </apex:pageBlockTable&...
Adrian Larson's user avatar
  • 150k
5 votes
Accepted

Invalid conversion from runtime type Boolean to List<>

Your problem is this area here: <apex:inputCheckbox value="{!wrapList}" onchange="enableDisable(this);"/> (There's a few instances of this problem, so only one is illustrated here.) You're ...
sfdcfox's user avatar
  • 491k
5 votes
Accepted

How to send List<Wrapper class> from Lightning component to Apex Controller?

Fixed using this approach. In Java script Callback, var actSave = component.get("c.saveDataDML"); actSave.setParams({ "listToSaveString": JSON.stringify(itemList) }); ...
Pasan Eeriyagama's user avatar
5 votes
Accepted

Wrapper Class in a Map

Use in the repeat caseInfo.CaseNumber Since caseInfo is akin to the loop variable in a for loop and each instance would be a wrapper record When using the repeats think of each one as a for loop. ...
Eric's user avatar
  • 54.2k
5 votes

Does Wrapper Class serve one purpose only?

I believe not. Wrapper class is a custom table in my belief. Though checkbox is a great example of it. But above it, I have been using Wrapper Classes beyond it's scope. Suppose there is a Custom ...
Saumya Gaikwad's user avatar
5 votes
Accepted

Not able to cover wrapper class in test class

Question 1: Your creating child class with parent class instance.trying doing this, Create child class instance with parent class Name. Syntax: OuterClass.InnerClass innerObject = new OuterClass....
NITHESH K's user avatar
  • 2,535
5 votes

SOQL Query Limits in Wrapper Class (using dlrs)

I guess you are confusing the standard practice with SOQL FOR Loop . SOQL For Loops are allowed, but standard practice is you do not write SOQL inside FOR loop. Like this: For(Contact c: contacts){ ...
Mr.Frodo's user avatar
  • 5,802
5 votes
Accepted

CompareTo - Sort order by date in Wrapper class

Based on your updates, simply compare calculatedDate between the passed in value (which you named other) and the instance calling the method. I find the following pattern readable and easy to ...
Adrian Larson's user avatar
  • 150k
5 votes

Adding a Wrapper Class to an External Class

You seem to have a name shadowing here. This code is adding CheckItemClass objects in a List<CheckItemClass> which is most likely declared in your controller as: List<CheckItemClass> ...
Jayant Das's user avatar
  • 30.6k
5 votes
Accepted

Custom Inline Editable Table in LWC

The detail parameter can contain complex data: this.dispatchEvent( new CustomEvent( 'update', { detail: { fieldName: this.fieldName, value: this.value } }...
sfdcfox's user avatar
  • 491k
5 votes
Accepted

How to serialize a string into a Blob value without backslashes?

In the given scenario, serialization occurs twice in the last three lines, and it is a cause of an observed scenario. A better way to approach this could be using of Map<String, Object> instead ...
kurunve's user avatar
  • 4,319
5 votes
Accepted

Getting error : Nested object for polymorphic foreign key must have an attributes field before any other fields

The deserialization needs to know what concrete type to use and that is signalled by an attributes field: "records":[{"attributes": {"type": "fund__c"}, "...
Keith C's user avatar
  • 136k
4 votes

Need to write a Wrapper Class

In relation to what is causing the problem, there is the question of whether the getter is called every time it is referenced in the page or not. The documentation says: It’s a best practice for ...
Keith C's user avatar
  • 136k
4 votes
Accepted

Implementing CompareTo In An Inner Class That Needs Outer Class Data

You can pass in a reference to the controller class in e.g. the constructor: public class WEvent implements Comparable { private ActivityListAttemptController controller; public Event e {get; ...
Keith C's user avatar
  • 136k
4 votes
Accepted

List index out of bounds exception in Wrapper Class Deletion

Let's assume in your list you have next elements [emp0, emp1, emp2, emp3] You want to remove element under index 1 and 3. After you remove index 1, you array becomes: [emp0, emp2, emp3] Now you ...
Ilya Lepesh's user avatar
  • 4,125
4 votes
Accepted

issue with wrapper variable

You have a public String property named w declared in the apex class which is not used in the class but conflicting with the apex:repeat loop variable which is also named w. So either change the ...
Santanu Halder's user avatar
4 votes
Accepted

Invalid type for my controller

On line 192 in your class you are incorrectly referencing your custom object. for (Business_Card_Request_Price_c i : tempList) { tmpWrp.add(new BCRWrapper(i)); } For custom objects, the API must ...
TSmith's user avatar
  • 5,002
4 votes

How can I have 100% code coverage in wrapper class + meaningful testing

Before working too hard on the tests take a second look at this code and improve it. Weak code with 100% test coverage is still weak code. List <Account> acc = new List <Account>(); List &...
Keith C's user avatar
  • 136k
4 votes
Accepted

Invalid Type for Comparable Implementation

CaseInfo is in the viewAllCaseCommentsActivitiesController class, so you need to use the fully-qualified name: List<viewAllCaseCommentsActivitiesController.CaseInfo> caseList = new List<...
sfdcfox's user avatar
  • 491k
4 votes
Accepted

Adding to sub list/array within apex wrapper class

You can create new instance of LineItem first like below since LineItem is a child class of Invoice so you have to use Invoice.LineItem to initialize the class Invoice.LineItem lineItem1 = new ...
Ratan Paul's user avatar
  • 22.7k

Only top scored, non community-wiki answers of a minimum length are eligible