0

I'm really confused / lost on this one. Writing a Query to select Opportunities not of Stage '6 - Closed Won' and it still pulls these records. This is happening with no other picklist values in the StageName field, i am able to sucessfully filter those out if i so choose (the below is of course only filtering out 6 - Closed Won

Query

SELECT Id, StageName, Lead_Producer__c, Account.Overseeing_Advisor__c  FROM 
Opportunity WHERE StageName != '6 - Closed Won'  

enter image description here

Stage Name and API are the same

enter image description here

  • 2
    Are you certain that all of those characters are hyphens and not en-dashes? I see at least one on your 2a stage that looks like an en or em dash. – David Reed Apr 2 at 17:15
  • Agree with David. It's incredibly easy to copy from a Microsoft Office product and get the "wrong" kind of dash. – sfdcfox Apr 2 at 17:29
  • I copy pasted from Salesforce to the Developer console – Bobbygllh Apr 2 at 17:35
  • And all others picklist values work (when copy pasting), even 2a which does appear to have an elongated dash – Bobbygllh Apr 2 at 17:38
  • Do you by any chance happen to have a space before/after the stage value? – Jayant Das Apr 2 at 17:53
1

This is most likely due to differences in em-dashes or spaces. I have had similar issues with picklist value API names in the past.

Try modifying your SOQL query to:

SELECT Id, StageName, Lead_Producer__c, Account.Overseeing_Advisor__c  FROM 
Opportunity WHERE (NOT StageName LIKE '%Closed Won')  

this should filter out the appropriate Opportunities

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.