• Mahanandeesh Belaganti
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 11
    Questions
  • 4
    Replies

 hi all.i wrote a class which cancels the record in object and i have to write  testclass for it.as iam new to salesforce i cant able to write.i have seen in many websites but i didnt understand.please  help in this, if possible please write a test class for below code.so that i can understand it.

public class  IRTACancelController{

    public PageReference cancelData1() {
    pagereference pr=new pagereference('https://otap-developer-edition.ap1.force.com/employees/apex/IRTAMENU');
      pr.setRedirect(true);
      return pr;
   
    }


    public String getDisp() {
        return null;
    }

    public boolean displayPopUp { get; set; }
   
   public boolean valid1{set;get;}
   public boolean valid2{set;get;}
   public boolean valid3{set;get;}
   public boolean valid4{set;get;}
   public boolean valid5{set;get;}
   public boolean valid6{set;get;}
  
   public boolean msg1{set;get;}
   public boolean msg2{set;get;}
   public boolean msg3{set;get;}
   public boolean msg4{set;get;}
   public boolean msg5{set;get;}
   public boolean msg6{set;get;}
    public boolean mess{set;get;}
     public boolean mess1{set;get;}

     public boolean visible{set;get;}
     public boolean visiblemsg{set;get;}
  

    public attachment attach {get; set;}
    public String IRTAId { get; set; }
    public String accts {set;}
    public IRTA__c ir{ get; set;}
    public IRTA__c IRTArecord {get;set;}
    public IRTA__c istatus {get; set;}
    public user u{set;get;}
    public Boolean page1{get;set;}
   
    public user emp;
    public static Boolean forApproval1{get;set;}
     public IRTA__c irDetail{get;set;}
    public IRTACancelController(ApexPages.StandardController controller){
        page1 = false;
      
       
       
    }
   
    /*  public PageReference saveData1() {
          PageReference page1;
            //forApproval1 = false;
           
   //  User u = [select name from User where id =: UserInfo.getUserId()];
       update IRTArecord;
  
        system.debug('this is the message');
        ir.employee_number__c=Userinfo.getUserId();
           IRTArecord.Status__c= 'Inactive';

        update IRTArecord;
        update emp;
        //visible=false;
      
        //visiblemsg=false;  // update emp;
        // getUpload();
       
     page1  = new PageReference('https://otap-developer-edition.ap1.force.com/employees/apex/IRTADetail?irtaId='+irtarecord.id);
        

        page1.setRedirect(true);
        return page1;
       
       
        }*/
   
   
   
    public IRTACancelController(){
        page1 = false;
       
      ir = new IRTA__c();
       
       
       // showMessage = false;
       
         emp= [select first_name__c,Region__c,SUBSBU__c,Reporting_manager_id__c,Reporting_manger_Name__c,Sbu_Head_Id__c,Sbu_Head_Name__c,Rpo_Id__c,Rpo_Name__c,Corporate_MATC_Id__c,Corporate_MATC_Name__c,Regional_MATC_Id__c,Regional_MATC_Name__c,CFO_Id__c,CFO_Name__c,MD_ID__c,MD_Name__c,Central_Travel_Desk_Id__c,Central_Travel_Desk_Name__c,Last_Name__c,Surname__c,Sex__c,age__c ,Emergency_Contact_Number__c,Emergency_Contact_Name__c,Mediclaim_insurance_required__c,Grade__c,Accounting_location__c,Employee_Number__c,Office_Number__c,Extension_Number__c,SBU_Dept__c,Mobile_Number__c,Project_Id__c,Designation__c,Manager_id__c,Passport_number__c,Valid_Upto__c,Date_of_Issue__c,Issued_at__c,Residential_Address__c,Date_of_Birth__c,Place_of_Birth__c,Issued_By__c, Manager_Name__c,Project_Name__c from user where id=:UserInfo.getUserID() limit 1];
        
        String irId = ApexPages.currentPage().getParameters().get('irtaId');
    
         if(String.isNotBlank(irId))
         {
           irDetail = [select name, Period__c,Visa_Type__c,Visa_Required__c,  Duration__c,Accommodation__c,All_expenses__c from IRTA__C where id=:irId limit 1];
         }
 
  
    }
   
   
        public List<SelectOption> getAccts(){
        List<selectOption> options = new List<selectOption>();
        options.add(new selectOption('', '- None -'));
        for (IRTA__c ir: [SELECT Id, Name,status__c FROM IRTA__c where employee_number__c=:Userinfo.getUserId() and status__c='Active']) {
       
        options.add(new selectOption(ir.id, ir.Name));
       
        }
        return options;
     }

 


  
    public void displayData(){
     try{
               u=[SELECT name from user where id=:Userinfo.getUserId() limit 1];
               }
               catch (System.QueryException e) {
                  System.debug('caught ya!');
                }
     
        IRTArecord = [SELECT Period__c,Visa_Required__c,Visa_Type__c,Accommodation__c,All_expenses__c,Duration__c,Status__c from IRTA__C  where id =:IRTAId];
       
       
    
        //System.debug('Hello');
        //System.debug(record);
        page1 = true;
      // displayPopup=true;
      // Id  id = IRTAId;
       // PageReference IRTAInfo = new PageReference('/apex/IRTAInfo?id='+id);
       // return IRTAInfo;
        //return null;
  }
 
 
 
    public PageReference pagechange()
    {
  
        return null ;
  
     
         }
       
/* PageReference  
pagereference pr=new pagereference('https://otap-developer-edition.ap1.force.com/employees/apex/IRTAMENU');
      pr.setRedirect(true);
      return pr;
 */    
    
   


 
public pageReference home()
      {
      pagereference pr=new pagereference('https://otap-developer-edition.ap1.force.com/employees/apex/IRTAMENU');
      pr.setRedirect(true);
      return pr;
      }  
 
   
  public PageReference getupload()
    {
  
        return null ;
  
      }
        
        
        
    public void closePopup(){
          displayPopup=false;
      }

    public void showPopup() {
       displayPopup=true;
       
    }


Public PageReference sendEmailFunction(){
PageReference page1;
          system.debug('this is the message'+ir.employee_number__c);
          ir.employee_number__c=Userinfo.getUserId();
          IRTArecord.Status__c= 'Inactive';
          update IRTArecord;
          update emp;
          //String id1=ApexPages.currentPage().getParameters().get('id');
          //IRTA__c irt=[select Name from IRTA__c where id=:id1];
           

    try{
      Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
   String[] toAddresses = new String[] {'vignesh@gmail.com' (mailto:{'vignesh@gmail.com')};
  // String[] ccAddresses = new String[] {'mahanandeesh@gmail.com' (mailto:{'mahanandeesh@gmail.com')};
   mail.setToAddresses(toAddresses);
  // mail.setCcAddresses(ccAddresses);
   mail.setSenderDisplayName('Cancellation');
   mail.setSubject('IRTA Booking Cancel');
   System.debug('IRTA DEBUG'+IRTArecord.Name);
   mail.setPlainTextBody('User ' +u.name+' Canceled irta request '+IRTArecord.Name);
   //mail.setHtmlBody('<b> This is HTML body </b>' );
   Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
  }
  catch(Exception e){}
   page1=new pagereference('https://otap-developer-edition.ap1.force.com/employees/apex/IRTADetail?irtaId='+irtarecord.id);
   page1.setRedirect(true);
   return page1;
 }
}


Hi All,

i want to update a picklist field 'status'(active,inactive) dynamically from community.please help me in this and pls send any code for it.


 thanks

i used a standard query of approval history which gives status of approval from workbench for community ,when i am executing it as administration it is working but when i tried it in community its not working means the page is working but it is not displaying data.please tell wheather the standard query works for customer community.if works tell me how.please as soon as possible
i want to save records(irta details) created in community in to salesforce (irta object) from community when i click save button.if any code requires please send it,i am new to this technology.please help me in this
 for my community,i created two objects, user object with approvestatusfield(picklist with 5 managers) and irta object with irta number field. what i want is when irta number is selected we should get at which manager(approval status field) the record is present i.e approval status.please help me in this problem.if any code  is required please send.try it as soon as possible
hi,
i want to display a single standard picklist field in visualforce pages this has to be retrieved from that object
Error Error: Could not resolve field 'AutoNumber' from <apex:inputField> value binding '{!emp.AutoNumber}' in page IRTANUMBER


thanks in A davance

Hi All,

i want to update a picklist field 'status'(active,inactive) dynamically from community.please help me in this and pls send any code for it.


 thanks

i want to display or retrieve a user fiels in visualforce pages 
  fields which are in customize! users!fields
which may be standard fields or custom fields



Thanks in Advance