• Saranraj
  • NEWBIE
  • 0 Points
  • Member since 2016
  • Salesforce Developer
  • Merfantz Technologies

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies
Hi all,
        I write the code for view the list of apex class name in VF page and select and delete the apex class name. But i got the error
Compile Error: DML not allowed on ApexClass at line 12 column 6.  how to fix to solve this error and how to delete the the apex class name in VF page Please help  below is my code...

public class RetrieveClasses{
  
  public void del(){
    List <ApexClass> li=new List <ApexClass>();
     for(sObjectWrapper wrap:wrappers)    
     {
      if(wrap.isSelected){
        li.add(wrap.apx);
      }
     }
     system.debug('dfddddd'+li);
     delete li;
     //li[0].status='Inactive';
    // update li;
    
    }
    
  public void triggerdel(){
   List <ApexTrigger> trggerlist=new List <ApexTrigger>();
   for(sObjectWrapper sobj:wrapp)
   {
      if(sobj.isSelected){
       trggerlist.add(sobj.apt);
       }
   }
   //delete trggerlist;
  }

  public List<sObjectWrapper> wrappers{get;set;}
  public List<sObjectWrapper> wrapp{get;set;}

public RetrieveClasses()
{
  wrappers=getdata();
  wrapp=gettrigger();
}
private List<sObjectWrapper> getdata(){
wrappers = new List<sObjectWrapper>();
for(ApexClass app:[select id,name,apiversion from ApexClass where apiversion=36.0])
{
   wrappers.add(new sObjectWrapper(app,false));
}
system.debug('deleteeeeeeeee===='+wrappers);
return wrappers;
}

private List<sObjectWrapper> gettrigger(){
List<sObjectWrapper> wrapper = new List<sObjectWrapper>();
for(ApexTrigger aptg:[select id,name from ApexTrigger])
{
wrapper.add(new sObjectWrapper(aptg,false));
}
system.debug('trigger values'+wrapper);

return wrapper; 
}
//public boolean isSelected{get;set;}

    public class sObjectWrapper{
    public boolean isSelected{get;set;}   
    public ApexClass apx{get;set;}
    public ApexTrigger apt{get;set;}

    
    public sObjectWrapper(ApexClass apx,Boolean isSelected){
     this.isSelected = isSelected;
     this.apx = apx;
    }
    public sObjectWrapper(ApexTrigger apt,Boolean isSelected){
     this.isSelected = isSelected;
     this.apt= apt;
    }
    
}
}
Hi Friends,

I need some accurate solution in date format, i think it's easy to salesforce developer . but i am new to salesforce .

I dispalyed  the date format like below 

 <apex:outputtext value="{0, date, medium}">
        <apex:param value="{!Inspection_Sheet__c.Date__c}"></apex:param>
    </apex:outputtext>

Output Is : Oct 21,2016

But I need a output like this --> 21st Oct 2016

Can Anyone help to me ASAP. 

I will be appreciate if you are come with the best solution .

Many Thanks In advance !!

Regards ,

SOUNDAR ,

+91-7418425418.
Hi all,
        I write the code for view the list of apex class name in VF page and select and delete the apex class name. But i got the error
Compile Error: DML not allowed on ApexClass at line 12 column 6.  how to fix to solve this error and how to delete the the apex class name in VF page Please help  below is my code...

public class RetrieveClasses{
  
  public void del(){
    List <ApexClass> li=new List <ApexClass>();
     for(sObjectWrapper wrap:wrappers)    
     {
      if(wrap.isSelected){
        li.add(wrap.apx);
      }
     }
     system.debug('dfddddd'+li);
     delete li;
     //li[0].status='Inactive';
    // update li;
    
    }
    
  public void triggerdel(){
   List <ApexTrigger> trggerlist=new List <ApexTrigger>();
   for(sObjectWrapper sobj:wrapp)
   {
      if(sobj.isSelected){
       trggerlist.add(sobj.apt);
       }
   }
   //delete trggerlist;
  }

  public List<sObjectWrapper> wrappers{get;set;}
  public List<sObjectWrapper> wrapp{get;set;}

public RetrieveClasses()
{
  wrappers=getdata();
  wrapp=gettrigger();
}
private List<sObjectWrapper> getdata(){
wrappers = new List<sObjectWrapper>();
for(ApexClass app:[select id,name,apiversion from ApexClass where apiversion=36.0])
{
   wrappers.add(new sObjectWrapper(app,false));
}
system.debug('deleteeeeeeeee===='+wrappers);
return wrappers;
}

private List<sObjectWrapper> gettrigger(){
List<sObjectWrapper> wrapper = new List<sObjectWrapper>();
for(ApexTrigger aptg:[select id,name from ApexTrigger])
{
wrapper.add(new sObjectWrapper(aptg,false));
}
system.debug('trigger values'+wrapper);

return wrapper; 
}
//public boolean isSelected{get;set;}

    public class sObjectWrapper{
    public boolean isSelected{get;set;}   
    public ApexClass apx{get;set;}
    public ApexTrigger apt{get;set;}

    
    public sObjectWrapper(ApexClass apx,Boolean isSelected){
     this.isSelected = isSelected;
     this.apx = apx;
    }
    public sObjectWrapper(ApexTrigger apt,Boolean isSelected){
     this.isSelected = isSelected;
     this.apt= apt;
    }
    
}
}