Skip to main content

HI I need help. I have a SOQL Query that has a checbox field  - Authorized_Purchaser__c - as on of  its attribute and wanted to check the value of this field in an IF condition statement but it seems that the value of the check box field is always true even when it is  unchecked(!?). I put debug statements on the  check box and it displays that it is true. However, after looking at it in the Affiliation object Detail Page,  I have seen that it is unchecked and thus should be false . Here is a portion of the code in question and checkbox field Authorized_Purchaser__c is the field I am trying to verify which is unchecked.  Thus it should be false however the value is set to true so the pricebook will never be added to the list of Price books. What am I missing?  Thanks much for your help.

boolean isAuthorized = true;

List<npe5__Affiliation__c> aff = [Select npe5__Organization__r.Registration_Level__c,Authorized_Purchaser__c,npe5__Organization__r.Name from npe5__Affiliation__c where npe5__Contact__c =: ContactId and npe5__Organization__r.Id =: AffID limit 1 ];

isAuthorized = aff[0].Authorized_Purchaser__c;

system.debug('<< IS AUTHORIZED? >>> '+aff[0]);

for( PriceBook2 PriceBook : [SELECT Id, Name FROM PriceBook2 Where isActive = true and Name in ('Employee Price Book','Contractor Price Book')    Order By Name DESC ]){

if(isAuthorized ==false && PriceBook.Name == 'Employee Price Book'){

CompanyPriceBooks.add(PriceBook);

}

}

 
5 个回答
  1. 2016年9月1日 22:11
    Please remember to mark best answer if this helped resolve your issue(s).
0/9000