0

I want to be able to render an error message on the page if a case record variable Closed_Days_Beyond_30_Days__c is true but unsure how to make this work. If the boolean is true, set the error message. If the boolean is false, then continue opening the modal.

VF

<apex:pageMessages id="caseErrorMessage" />
<apex:outputPanel rendered="{!oCase.Status=='Closed'}">
<a href="javascript:void(0)" reRender="caseErrorMessage" class="btn btn-default cbtnclose cBtnNew" data-toggle="modal" data-target="#myModal_Open"></a>
</apex:outputPanel>

Controller

public void doClosedCaseValidation(){
    if(oCase.Closed_Days_Beyond_30_Days__c)
    {
        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.FATAL,'This case has been closed for more than five (5) business days. Please submit a new case and reference this case number for prompt assistance.'));
    }
}

1 Answer 1

0

You can do this with apex:pageMessage

  <apex:pageMessage rendered="{!hasCaseClosedError}" severity="2" 
        summary="This case has been closed for more than five (5) business days. Please submit a new case and reference this case number for prompt assistance."/>

In your controller

public Boolean hasCaseClosedError {
  get {
     return ... your logic here ...
  } private set;
}

Alternative

Or, you can do this without the controller logic if the oCase variable is exposed to the VF page with a public getter

<apex:pageMessage rendered="{!oCase.Closed_Days_Beyond_30_Days__c}" severity="2" 
        summary="This case has been closed for more than five (5) business days. Please submit a new case and reference this case number for prompt assistance."/>

Alternative 2

If the VF page is associated to a standardController (i.e. not a custom controller), and oCase is the same as the standard Case record that the page is invoked on

<apex:pageMessage rendered="{!Case.Closed_Days_Beyond_30_Days__c}" severity="2" 
        summary="This case has been closed for more than five (5) business days. Please submit a new case and reference this case number for prompt assistance."/>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .