You need to sign in to do that
Don't have an account?
tonante
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.
Verifying Checkbox field value from a SOQL using Apex class.
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); } }
All Answers
- Check if you are referring to the correct record, debug aff[0].Id and verify if in the page layout you see the same record
- check if the default value of the field is set to 'Checked', you can see this by going to setup=>create=>object=>field
A screenshot would help to debug futher.Cheers!
Hope this helps!
AM