SFDC Code Snippets


List Map Preperation:


List<Account> Acclist =new List<Account>();

Acclist =[SELECT Id,name FROM Account where name like '%TEST%'];

Map<Id,String> AccountMap=new Map<Id,String>();


Set<String> AccName =new Set<String>();

for (Account accfor :Acclist)
{
    AccName.add(accfor.Name);
AccountMap.put(accfor.Id,accfor.Name);

}



Map <String,Boolean> Firutornot =new Map<String, Boolean>{'Apple'=>true,'Bread'=>false,'orange'=> true,'meat'=>false};
System.debug('here MAC'+Firutornot);

Firutornot.put('Apple',false);

System.debug('After update'+Firutornot);

--------------
public class NewWrapperClass1 {
  public  String Name;
  public  double Salary;

}
----------------------
Calling Wrapper class:

NewWrapperClass1 f1=new NewWrapperClass1();
f1.Name='ABC';
f1.Salary=1000;

NewWrapperClass1 f2=new NewWrapperClass1();

f2.Name='DEF';
f2.Salary=2000;

List<NewWrapperClass1> flist=new List<NewWrapperClass1>();
flist.add(f1);
flist.add(f2);
System.debug('flist'+flist);
---------------
----
public class Emp {

    public String Name;
    public integer Id;
 
}
-----
public class EmployeeData {
   
    public Emp e;
   
    public EmployeeData(){
       
        e= new Emp();
       
        e.Name='Ganesh';
        e.Id=100;
    }
   

}
---Calling from Anonymous window:

EmployeeData ed=new EmployeeData();
System.debug('ed'+ed.e.Name);
----
public class AddressClass {
   
    public string StreetName;
    public string City;
    public string State;
    public integer Code;
     
}

public class EmployeeAddressData {
   
    public String namepc;
    public Double salpc;
   
    public AddressClass addclass;
   
    public EmployeeAddressData(String namevrbl,Double salvrbl,String StreetName,String City,String State,integer Code)
    {
     
        this.namepc=namevrbl;
        this.salpc=salvrbl;
        addclass=new AddressClass();
        addclass.StreetName=StreetName;
        addclass.State=State;
        addclass.City=City;
        addclass.Code=Code;
       
    }
   

}
---
EmployeeAddressData ed1= new EmployeeAddressData('Ram',1000,'3rd Line','Hyd','TS',50089);
EmployeeAddressData ed2= new EmployeeAddressData('Shaym',2000,'4rd Line','Hyd','TS',50090);

List<EmployeeAddressData> Listed=new list<EmployeeAddressData>();

Listed.add(ed1);
Listed.add(ed2);

System.debug('Listed'+Listed);

---

Comments

Popular posts from this blog

Human's : Master's of Misuse