I have a error manager rule in controller at quote line item level. Scenario is whenever a particular product 'X' is added by the sales manager ... dates field should be filled in. But if the same product is added Inside sales manager it by passes error manager.. But I need bypass this error manager when that product is added by inside sales manager and Outside sales manager trying to edit or add more products to the quote. below is my code ...

if(quoteWrap.productCode.contains('ANN')) {
                 if ((quoteWrap.quoteLineItem.Number_of_Terms__c != null || quoteWrap.quoteLineItem.Number_of_Terms__c == 0.000) && quoteWrap.quoteLineItem.CreatedBy.Id != '00560000001dk88') {
                IntVal = quoteWrap.quoteLineItem.Number_of_Terms__c.intValue();

                if(IntVal == 0) {
                    IsANN = false;
                } else if (IntVal == 0 && quoteWrap.quoteLineItem.CreatedBy.Id == '00560000001dk88') {
                    IsANN = true;
                } else {    
                    String decimaltoCompare = String.Valueof(IntVal) + '.0';

                    if (decimaltoCompare != String.Valueof(quoteWrap.quoteLineItem.Number_of_Terms__c)) {
                        IsANN = false;
               if(mode == 'Edit' && quoteWrap.numOfdays == quoteWrap.quoteLineItem.Number_of_Terms__c) {
                   IsANN = true;

List<profile> prof=new List<profile>();    
    prof=[select id,name from profile where id=:prfileid];
        if (!itemsToInsertOrUpdate.isEmpty()) { 

 if (IsANN == false && (prof[0].name=='Sales User'||prof[0].name=='Sales Engineer'||prof[0].name=='AMS Manager'||prof[0].name=='Sales Director')) {             
                ErrorManager('1 year duration is must');
                return null;
  • Where are you actually performing the validation? In a Validation Rule? If so the page itself seems irrelevant. Unless you want the bypass to only apply for this one page?
    – Adrian Larson
    Commented Apr 28, 2016 at 16:36
  • @AdrianLarson: Actually there was a VR where it checks for the Dates for product 'X' at quote line item level whenever that product is added by Sales Users profile and it excludes Inside Sales Managers... So whenever whenever Sales users needs to add that product without dates they usually request Inside Sales Managers. But after ISR adding that product to the quote, Sales users couldn't able to add/edit OPP/QUOTE/ add other products due to VR on their profile.. inorder to bypass that I have inactivated and replicated that VR in controller...
    – Gidy
    Commented Apr 29, 2016 at 15:50


You must log in to answer this question.

Browse other questions tagged .