Activity Forums Salesforce® Discussions Change case status only though Visualforce page

  • Himanshu

    Member
    May 27, 2016 at 11:57 am

    Hi Nitish,

    Try this code:-
    public class CaseControl {
    public static Boolean allowReopen = false;

    public static void verifyReopen(Case[] prior, Case[] current) {
    if(!allowReopen) {
    for(Integer index = 0, size = current.size(); index < size; index++) {
    if(prior[index].Status == 'Closed' &&
    current[index].Status <> 'Closed') {
    current[index].addError('Please use the Visualforce page to reopen this case.');
    }
    }
    }
    }
    }

     

    Trigger:-
    trigger verifyReopen on Case (after update) {
    CaseControl.verifyReopen(Trigger.old, Trigger.new);
    }

     

    Case Reopen:-
    public PageReference reopenAndSave() {
    CaseControl.allowReopen = true;
    caseRecord.Status = 'Reopened';
    update caseRecord;
    return new ApexPages.StandardController(caseRecord).view();
    }

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos