You need to sign in to do that
Don't have an account?
James Roberts 32
Problem showing error in visual force table
I'm having trouble adding custom error messages into my visual force table.
I have created the Error Controller extension and added it to my VF page, but I am still getting the standard error message, without the graphic:
Update failed. First exception on row 0 with id a1H55000006jCXLEA2; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Your pricing is already approved. To reduce the pricing by more than 10% you will need a new approval.: []
Error is in expression '{!save}' in component <apex:commandButton> in page pricingtable3years: Class.PricingTable.save: line 22, column 1
Controller:
public with sharing class ErrorMessageInVfController {
public Opportunity_Pricing__c op{get;set;}
public ErrorMessageInVfController(ApexPages.StandardController controller) {
op = (Opportunity_Pricing__c)controller.getRecord();
}
public void save(){
if(op.Pricing_Sheet_Approved__c = TRUE && (op.Average_MRR__c < (op.Approved_MRR__c*0.9)) )
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.FATAL,'Your pricing is already approved. To reduce the pricing by more than 10% you will need a new approval.'));
}
}
Visual Force page Extract:
<apex:page standardController="Opportunity_Pricing__c" extensions="PricingTable,ErrorMessageInVfController" lightningStylesheets="true">
<apex:slds />
<apex:form >
<apex:pageBlock >
<apex:pageMessages id="showmsg"></apex:pageMessages>
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}" oncomplete="ReloadPage();" rerender="showmsg" />
</apex:pageBlockButtons>
<table>
<tr >
<th></th>
<th>Included</th>
<th>Year 1</th>
<th>Year 2</th>
<th>Year 3</th>
</tr>
I have created the Error Controller extension and added it to my VF page, but I am still getting the standard error message, without the graphic:
Update failed. First exception on row 0 with id a1H55000006jCXLEA2; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Your pricing is already approved. To reduce the pricing by more than 10% you will need a new approval.: []
Error is in expression '{!save}' in component <apex:commandButton> in page pricingtable3years: Class.PricingTable.save: line 22, column 1
Controller:
public with sharing class ErrorMessageInVfController {
public Opportunity_Pricing__c op{get;set;}
public ErrorMessageInVfController(ApexPages.StandardController controller) {
op = (Opportunity_Pricing__c)controller.getRecord();
}
public void save(){
if(op.Pricing_Sheet_Approved__c = TRUE && (op.Average_MRR__c < (op.Approved_MRR__c*0.9)) )
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.FATAL,'Your pricing is already approved. To reduce the pricing by more than 10% you will need a new approval.'));
}
}
Visual Force page Extract:
<apex:page standardController="Opportunity_Pricing__c" extensions="PricingTable,ErrorMessageInVfController" lightningStylesheets="true">
<apex:slds />
<apex:form >
<apex:pageBlock >
<apex:pageMessages id="showmsg"></apex:pageMessages>
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}" oncomplete="ReloadPage();" rerender="showmsg" />
</apex:pageBlockButtons>
<table>
<tr >
<th></th>
<th>Included</th>
<th>Year 1</th>
<th>Year 2</th>
<th>Year 3</th>
</tr>
if(op.Pricing_Sheet_Approved__c && (op.Average_MRR__c < (op.Approved_MRR__c*0.9)) )