public String strCaseId = ApexPages.currentPage().getParameters().get('id'); public String strClosingComments {get; set;} public Case objCancelCase {get; set;} public List<CaseComment> objCancelCaseCommentList {get; set;}
public CancelCase(ApexPages.StandardController controller) { strClosingComments =''; objCancelCaseCommentList = [Select Id, ParentId, IsPublished, CommentBody, CreatedById, CreatedDate, SystemModstamp, LastModifiedDate, LastModifiedById, IsDeleted, ConnectionReceivedId, ConnectionSentId From CaseComment where ParentId =:strCaseId ]; }
public List<SelectOption> getStatus(){ List<SelectOption> options = new List<SelectOption>(); Schema.DescribeFieldResult fieldResult = Case.Status.getDescribe(); options.add(new SelectOption('Cancelled', 'Cancelled')); return options; }
public PageReference save() {
PageReference createCancelCase; try{ if(strClosingComments==null || strClosingComments==''){ ApexPages.addMessage(new ApexPages.message(ApexPages.severity.error,'You must enter Comments')); return null; }
//strCaseId Case caseBeingCancelled = [Select Status From Case where Id=:strCaseId]; caseBeingCancelled.Status = 'Cancelled'; update caseBeingCancelled;
createCancelCase = new PageReference('/'+strCaseId); createCancelCase.setRedirect(TRUE);
http://wiki.developerforce.com/index.php/An_Introduction_to_Apex_Code_Test_Methods