I have an after insert after update Trigger which is responsible for calculating value of a variable. Depending upon the calculated value, I have to display a message to user on a VF page( not error message). How am I supposed to do that?Below is the code for the page, but it still doesnt work.

 <apex:page controller="ApplicantController" showHeader="false" sidebar="false" docType="html-5.0" tabStyle="Applicant__c"  >
<apex:form styleClass="myFormStyle" id="myFrom">
  <apex:actionFunction name="Save" action="{!save}" rerender="myForm,pageMessages,amount" status="statusSaveTrip" />
<apex:pageMessages id="pageMessages"/>
      <!--<th>Type of Loan</th>-->
            <td><apex:inputField required="true"  value="{!applicant.Type_of_Loan__c}" styleClass="form-control" /></td>
            <td><apex:inputField required="true"  value="{!applicant.Loan_Amount__c}" styleClass="form-control" /></td>
            <td><apex:inputField required="true"  value="{!applicant.Loan_Tenure__c}" styleClass="form-control" /></td>

       <!-- </div>-->

         <apex:outputpanel id="amount">
                var successMsg = '{!SuccessMsg}';
                console.log('successMsg ---'+successMsg);
          Loan status: &nbsp; &nbsp; &nbsp; <apex:outputText value="{!SuccessMsg}"/>


           EMI amount: &nbsp; &nbsp; &nbsp; <apex:outputText value="{!emi}"/>
            <apex:actionSupport event="onclick" 
                            rerender="amount" status="whileStatus"/>





    <div align="center" draggable="false">

    <apex:commandButton onclick="Save()" value="Save" style="float:centre" styleClass="btn btn-default" rerender="myForm,pageMessages,amount" status="statusSaveTrip"/>
    <apex:pageMessage summary="My error message" severity="info"
              rendered="{!SuccessMsg = 'Sucess'}"/>

    <apex:commandButton value="Cancel" style="float:centre" styleClass="btn btn-default"/>


  • 2
    Create visualforce page, create method that update record, after record has been updated, get newly calculated field value, determine message text based on that, call apexPages.addMessage with severity and message text. done) – kurunve Apr 27 '16 at 7:45
  • Can you explain this with an example code? – Jyoti Zanwar Apr 27 '16 at 8:07
  • 1
    What have you tried so far Jyoti? SFSE isn't a good place to get people to write code for you, but it's a great place to get advice on a specific issue. – Matt Lacey Apr 27 '16 at 23:59

You don't indicate whether the save action (which invokes the trigger), redirects to the same or different VF page but regardless, whatever VF page is displayed after the save occurs, add this line:

<apex:pageMessage summary="My error message" severity="info"
                  rendered="{!someGetter = 'foo'}"/>

If the controller value returned by someGetter has the value of foo, then the message displays.

If the page uses a standardController, then something like:

<apex:pageMessage summary="My error message" severity="info"
                  rendered="{!theSobject.theField__c = 'foo'}"/> 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.