• KrisGopi
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 3
    Replies

Hi ,Friends and Apex Developers please help me . I created a Apex Class and i write a test Case but it covers only 25% please help me that i have to reach this Coverage level in to 80% at  least , it is very urgent for me please do need fully

Base: I create a Customfield  in Case  reply__c and i create a CustomObject Reply __c  then i created a visualforce page  in this i created a Submit button then the reply go to the cocerned customer .

here is the class

 

 

public class Reply

{

public Case objCase

{ get; set; }

 

public CaseReply__c objCaseReply

{ get; set; }

 

public User objUser

{ get; set; }

 

public String EmailBody

{ get; set; }

 

public Reply()

{

objCase = [Select Subject,Requestor_Email__c, OwnerId, Id, Description,Priority,CreatedDate, Contact.Email,Contact.Name, CustomerOf__c, Contact_Email_Alias__c, ContactId, CaseNumber,ReplyStatus__c, CaseReply__c From Case where id = :ApexPages.currentPage().getParameters().get('id')];

EmailBody = 'Add your reply here!!!';

}

 

public void save()

{

//As per email review logic, check manual approval or auto

Case oCase = [Select Id,Subject,ReplyStatus__c From Case where id = :ApexPages.currentPage().getParameters().get('id')];

CaseReply__c oCaseReply = new CaseReply__c();

oCaseReply.AgentReply__c = emailBody ;

oCaseReply.Name = oCase.Subject;

oCaseReply.rCase__c = oCase.Id;

insert oCaseReply;

Boolean checkFlag = ReviewAgentEmail();

 

if(checkFlag == true){

oCase.ReplyStatus__c = 0;

update oCase;

}else{

oCase.ReplyStatus__c = 2;

update oCase;

//send direct email and mark case as replied

sendEmail();

}

updateEmailCount();

}

public boolean ReviewAgentEmail()

{

User oUser =[Select EmailCount__c from User where Id =:UserInfo.getUserId()];

Double currentEmailcount;

 

if(oUser.EmailCount__c == null)

{

currentEmailcount = 0;

}

else

{

currentEmailcount = oUser.EmailCount__c;

}

if(currentEmailCount == 10)

{

currentEmailcount = 1;

}

else

{

currentEmailcount = currentEmailcount + 1;

}

 

EmailReview__c emailRev = [Select DoReview__c, EmailNum__c from EmailReview__c where EmailNum__c =:currentEmailCount and Name =:UserInfo.getUserId()];

 

if(emailRev.DoReview__c == 1)

{

return true;

}

else

{

return false;

}

}

 

public void updateEmailCount()

{

User oUser = [Select EmailCount__c from User WHERE id=:UserInfo.getUserId()];

 

if(oUser.EmailCount__c == 10){

oUser.EmailCount__c = 1;

}else{

oUser.EmailCount__c = oUser.EmailCount__c + 1;

}

update oUser;

}

 

public void sendEmail()

{

Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();

String[] to_Address = new String[]{};

String[] cc_Address = new String[]{};

String[] bcc_Address = new String[]{};

 

if(objCase.Contact.Email != null)

to_Address.add(objCase.Contact.Email);

if(objCase.Requestor_Email__c != null)

to_Address.add(objCase.Requestor_Email__c);

 

to_Address.add('ganeshd@cybage.com');

mail.setToAddresses(to_Address);

 

if(objCase.Contact_Email_Alias__c != null)

cc_Address.add(objCase.Contact_Email_Alias__c);

mail.setCcAddresses(cc_Address);

 

User objUser = [Select Email from User where Id =:UserInfo.getUserId()];

 

if(objUser.Email != null)

mail.setReplyTo(objUser.Email);

 

mail.setSaveAsActivity(true);

mail.setSubject(objCase.Subject);

mail.setHTMLBody(emailBody);

mail.setPlainTextBody(emailBody);

Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });

}

 

}

Advance thanks to all

 

 

Hi All,

Give me some idea on cases that i create a customfield reply__c in case and i create a ApexClass Agentreply and my problem is Write a test Case with 75 % please help me it is very urgent............

 public class AgentReply
{
 
    public Case objCase
    {    get;    set;    }
  
    public CaseReply__c objCaseReply
    {    get;    set;    }
 
    public User objUser
    {   get;    set;    }
 
    public String EmailBody
    {    get;    set;    }
    
 
    public AgentReply()
    {
        
        objCase = [Select Subject,Requestor_Email__c, OwnerId, Id, Description,Priority,

           ...... CaseReply__c From Case where id = :ApexPages.currentPage().getParameters().get('id')];
      
        EmailBody = 'Add your reply here!!!';
    }
    
  
      // this method is call from the Visualforce page to save the Reply in the CaseReply__c  Custom object
    public void save()    
    {           
        //As per email review logic, check manual approval or auto


        Case oCase = [Select Id,Subject,ReplyStatus__c From Case where 

         id=:ApexPages.currentPage().getParameters().get('id')];
        CaseReply__c oCaseReply   = new CaseReply__c();
        oCaseReply.AgentReply__c = emailBody ;
        oCaseReply.Name = oCase.Subject;
        oCaseReply.rCase__c = oCase.Id;
        insert oCaseReply;   

        Boolean checkFlag = ReviewAgentEmail();
                  
        if(checkFlag == true)
        {
            oCase.ReplyStatus__c = 0;
            update oCase;
        }
        else
        {
            oCase.ReplyStatus__c = 2;
            
            update oCase;
            
            //send direct email and mark case as replied
            sendEmail();
            
        }                
        updateEmailCount();
    }
    
    
    // Method of updateEmailCount
    
    public void updateEmailCount()
    {
        User oUser = [Select EmailCount__c from User WHERE id=:UserInfo.getUserId()];
        
        if(oUser.EmailCount__c == 10){
            oUser.EmailCount__c = 1;
        }else{
            oUser.EmailCount__c = oUser.EmailCount__c + 1;
        }
        update oUser;
    }
    
    // Method of send Email process
    public void sendEmail()    
    {
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();                
        String[] to_Address = new String[]{};    
        String[] cc_Address = new String[]{};
        String[] bcc_Address = new String[]{};
        
        if(objCase.Contact.Email != null)        
        to_Address.add(objCase.Contact.Email);   
        if(objCase.Requestor_Email__c != null)        
        to_Address.add(objCase.Requestor_Email__c);     
       
        to_Address.add('ganeshd@cybage.com');
        mail.setToAddresses(to_Address);
        
        if(objCase.Contact_Email_Alias__c != null)
        cc_Address.add(objCase.Contact_Email_Alias__c);  
        mail.setCcAddresses(cc_Address);
        
        User objUser = [Select Email from User where Id =:UserInfo.getUserId()];
        
        if(objUser.Email != null)
        mail.setReplyTo(objUser.Email);
        
        mail.setSaveAsActivity(true);       
        mail.setSubject(objCase.Subject);         
        mail.setHTMLBody(emailBody);  
        mail.setPlainTextBody(emailBody);
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });                                
    }
    
    // Method for ReviewAgentEmail
    public boolean ReviewAgentEmail()
    {
        User oUser =[Select EmailCount__c from User where Id =:UserInfo.getUserId()];
        Double currentEmailcount;
        
        if(oUser.EmailCount__c == null)
        {
            currentEmailcount = 0;
        }
        else
        {
            currentEmailcount = oUser.EmailCount__c;    
        }
        if(currentEmailCount == 10)
        {
            currentEmailcount = 1;
        }
        else
        {
            currentEmailcount = currentEmailcount + 1;
        }
           
        EmailReview__c emailRev = [Select DoReview__c, EmailNum__c from EmailReview__c  where EmailNum__c =:currentEmailCount and Name =:UserInfo.getUserId()];
        
        if(emailRev.DoReview__c == 1)
        {
            return true;
        }
        else
        {
            return false;
        }
     }
}

 

 

give me  some idea on this issue

 

thanks u guys.......

Hi all SF members I create Custom Object Agent and Manager then Agent send the mails to many users through Email ---Subject,To,Description  then saved this details in database . Agent Sensed mails r first send to the Manager Custom Object then Approval that mails after approval that mails will be send to the Users.

Based on the above requirement please give me some idea that hoe send mails using Visual Force , Apex .

Give me Some idea on the fallowing flow

 

Agent-Email-Users-Got Approval of Manager - After Approval Email send to the User - finally data will be stored in database

I have a list see below in this on click on the Top button the selected field is on Top  in the same List .

Same as all like selct the one or multi selections then all the fields with the selcting priority they changed

 

name

city-----select on this field and click on the bottom button it will swap and go to bottom of the list

street     top---button

phone     bottom--button

email

country------select on this field and click on the top button it will swap and go to top of the list     

Fname

LastNAme    

any give me some example code to Describe object
Give me some idea on that how to use detal,panelgrid

Hai ,buddies i have problem with code ,that we add a add,Save buttons to a page and display the customFields any of 3 fields ex-Name,Departement from Employee and  if we click on  add  then add the new row and same as all that means i have to show the page as a Multi Add Page and above all added pages we given enter the values the all will be save in the Custom object and allso we delete the  a perticular row tha we selected using a 'action button ' .

 

 :manhappy:

u any give me the ActionRegion example with all attributes
any example code How to use Onsubmit.oncomplete in ActionPoller in visualforce any example that use all attributes in one example 

Hi ,Friends and Apex Developers please help me . I created a Apex Class and i write a test Case but it covers only 25% please help me that i have to reach this Coverage level in to 80% at  least , it is very urgent for me please do need fully

Base: I create a Customfield  in Case  reply__c and i create a CustomObject Reply __c  then i created a visualforce page  in this i created a Submit button then the reply go to the cocerned customer .

here is the class

 

 

public class Reply

{

public Case objCase

{ get; set; }

 

public CaseReply__c objCaseReply

{ get; set; }

 

public User objUser

{ get; set; }

 

public String EmailBody

{ get; set; }

 

public Reply()

{

objCase = [Select Subject,Requestor_Email__c, OwnerId, Id, Description,Priority,CreatedDate, Contact.Email,Contact.Name, CustomerOf__c, Contact_Email_Alias__c, ContactId, CaseNumber,ReplyStatus__c, CaseReply__c From Case where id = :ApexPages.currentPage().getParameters().get('id')];

EmailBody = 'Add your reply here!!!';

}

 

public void save()

{

//As per email review logic, check manual approval or auto

Case oCase = [Select Id,Subject,ReplyStatus__c From Case where id = :ApexPages.currentPage().getParameters().get('id')];

CaseReply__c oCaseReply = new CaseReply__c();

oCaseReply.AgentReply__c = emailBody ;

oCaseReply.Name = oCase.Subject;

oCaseReply.rCase__c = oCase.Id;

insert oCaseReply;

Boolean checkFlag = ReviewAgentEmail();

 

if(checkFlag == true){

oCase.ReplyStatus__c = 0;

update oCase;

}else{

oCase.ReplyStatus__c = 2;

update oCase;

//send direct email and mark case as replied

sendEmail();

}

updateEmailCount();

}

public boolean ReviewAgentEmail()

{

User oUser =[Select EmailCount__c from User where Id =:UserInfo.getUserId()];

Double currentEmailcount;

 

if(oUser.EmailCount__c == null)

{

currentEmailcount = 0;

}

else

{

currentEmailcount = oUser.EmailCount__c;

}

if(currentEmailCount == 10)

{

currentEmailcount = 1;

}

else

{

currentEmailcount = currentEmailcount + 1;

}

 

EmailReview__c emailRev = [Select DoReview__c, EmailNum__c from EmailReview__c where EmailNum__c =:currentEmailCount and Name =:UserInfo.getUserId()];

 

if(emailRev.DoReview__c == 1)

{

return true;

}

else

{

return false;

}

}

 

public void updateEmailCount()

{

User oUser = [Select EmailCount__c from User WHERE id=:UserInfo.getUserId()];

 

if(oUser.EmailCount__c == 10){

oUser.EmailCount__c = 1;

}else{

oUser.EmailCount__c = oUser.EmailCount__c + 1;

}

update oUser;

}

 

public void sendEmail()

{

Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();

String[] to_Address = new String[]{};

String[] cc_Address = new String[]{};

String[] bcc_Address = new String[]{};

 

if(objCase.Contact.Email != null)

to_Address.add(objCase.Contact.Email);

if(objCase.Requestor_Email__c != null)

to_Address.add(objCase.Requestor_Email__c);

 

to_Address.add('ganeshd@cybage.com');

mail.setToAddresses(to_Address);

 

if(objCase.Contact_Email_Alias__c != null)

cc_Address.add(objCase.Contact_Email_Alias__c);

mail.setCcAddresses(cc_Address);

 

User objUser = [Select Email from User where Id =:UserInfo.getUserId()];

 

if(objUser.Email != null)

mail.setReplyTo(objUser.Email);

 

mail.setSaveAsActivity(true);

mail.setSubject(objCase.Subject);

mail.setHTMLBody(emailBody);

mail.setPlainTextBody(emailBody);

Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });

}

 

}

Advance thanks to all

 

 

Hai ,buddies i have problem with code ,that we add a add,Save buttons to a page and display the customFields any of 3 fields ex-Name,Departement from Employee and  if we click on  add  then add the new row and same as all that means i have to show the page as a Multi Add Page and above all added pages we given enter the values the all will be save in the Custom object and allso we delete the  a perticular row tha we selected using a 'action button ' .

 

 :manhappy: