Skip to content
  • linkedIn
  • twitter
  • About Us
  • News letter
  • Privacy Policy
  • Contact Us
sfdcgenius

sfdcGenius

Learn Practice and Execute

salesforce
  • Home
  • Blog
  • Apex
  • Toggle search form
Wrapper class in salesforce

What is Wrapper Class in Salesforce Apex?

Posted on January 6, 2023January 19, 2023 By sfdcGenius No Comments on What is Wrapper Class in Salesforce Apex?

What is Wrapper Class in Salesforce Apex?

Wrapper Class in Salesforce Apex A wrapper or container class is a class, a data structure, or an abstract data type that contains different objects or collections of objects as its members.

A wrapper class is a custom object described by a programmer in which he defines the wrapper class properties. Consider a custom object in salesforce, what do you have in it? fields right?  different fields of various data types. Similarly wrapper class is a custom class that has different  data types or properties as per requirement. We can wrap  different  object types  or another types in a wrapper class.

do you know how to count child records on parents? trigger to count the number of related child records on the parent.

Below example, we have created our own list with two different data types.

public class wrapper {
      public void callwrapper(){
        List<wrapperclass> lst=new List<wrapperclass>();
          contact cnn=[select id,firstname from contact limit 1];
        for(Account acc_new:[select id,name from Account]){
          wrapperclass obj=new wrapperclass(acc_new);
          lst.add(obj);
        }
           
           
           wrapperclass obj1=new wrapperclass(cnn);
           lst.add(obj1);
           system.debug(lst.size());
      }
      public class wrapperclass{
            public string name;
            public wrapperclass(Account x1){
                name=x1.name;    
            }
            public wrapperclass(contact x1){
                name=x1.firstname;    
            }
           
        }  
}

For any Query/doubt comment below and for quick response LinkedIn and Twitter.

Related Post

Apex, Apex Class, Customization, Recent Post Tags:Apex, Apex Class, Apex Trigger, salesforce latest update, salesforce layoff, wrapper class in apex, wrapper class in salesforce

Post navigation

Previous Post: What is Modal/Popup in Lightning Web Component(LWC)?
Next Post: What are Decorators in Lightning Web Component (LWC)?

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Categories

  • Admin
  • Apex
  • Apex Class
  • Apex Triggers
  • Customization
  • Flow
  • Lightning Web Component
  • Ligthing
  • LWC
  • Recent Post
  • Salesforce Security

Tags

@api @track @wire Admin Apex Apex Class Apex Trigger api connectedCallback() decorators disconnectedCallback disconnectedCallback() errorCallback errorCallback() Flow How to check whether record values are changed or not in Apex Trigger how to create modal in lwc how to create popup in lwc lighting flow LightningAlert LightningConfirm LightningPrompt lightning web component lwc modal/popup in lwc Modal in lwc notification in lwc popup in lwc renderedCallback() Role Hierarchies Salesforce Salesforce Customization salesforce flow salesforce latest update salesforce layoff sfdc sfdcGenius sfdcginus track trailhead Trigger.NewMap Vs Trigger.oldMap trigger.old vs Trigger.New wire wrapper class in apex wrapper class in salesforce

Resources

  • About Us
  • Blog
  • Contact Us
  • Home
  • Newsletter
  • Privacy Policy

Social Media

  • linkedIn
  • twitter

Copyright © 2025 sfdcGenius.

Powered by PressBook WordPress theme