• Danny@KCTS
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

Hi,

 

I have a simply query in my apex class to return a record from a custom object, code below:

 

userIncentivePlan = [select name, isActive__c, owner.name, Target__c, Growth_Incentive_Rate__c from Incentive_Plan__c where user__c =:UserId and isActive__c='True'];

 With the "isActive__c = 'True'" where criteria, the query fails to return any results, therefore I am assuming it  always evaluates to false. (also confirmed this by printing it out to a visual force page)

 

the formula on the field contains some nested if statements but always equates to 'True' or 'False', code below:

 

if (User__r.Profile.Name = 'System Administrator',  Incentive_Rate__r.isActive__c , 
if (User__r.Profile.Name = 'Corporate Sales Manager', Incentive_Rate__r.isActive__c, 
if (User__r.Profile.Name = 'Corporate Account Developer', Growth_Incentive_Rate__r.isActive__c, 
if (User__r.Profile.Name = 'Corporate Account Manager', Growth_Incentive_Rate__r.isActive__c, 
if (User__r.Profile.Name = 'Corporate Sales Super User', Incentive_Rate__r.isActive__c, 
if (User__r.Profile.Name = 'Account Development Manager', 
  if ( AND ( Incentive_Rate__r.isActive__c ='True',  Growth_Incentive_Rate__r.isActive__c ='True'), 'True', 'False'), 'False')
))))) 

The isActive__c field reference on the incentiveRate object is also a formula field [could that be the cause of the problem??]

 

Strangely, when I view the custom object record through salesforce, it evaluates correctly to 'True'

 

Having seen this forum posing, it suggests what I have done is correct : link

.... however it is not working. 

 

Any suggestions on how I can go about trying to resolve this would be appreciated.

 

Thanks in advance.

  • June 27, 2012
  • Like
  • 0