+ Start a Discussion
Debendra Ray 8Debendra Ray 8 

== operator is returning false although the operands are same in apex


Issue is : == operator is returning false although the operands are same on both sides of the operator  - statement is below:

System.debug('DEBUG:approvalForProposalPricingDeviation::: BEGIN INVOKATION ********quNew.Status---->'+quNew.Status );-- This prints out the value : Pending Approval with RM-West for Pricing Deviation
if(quNew.Status == 'Pending Approval with RM-West for Pricing Deviation'  ){
System.debug('DEBUG:approvalForProposalPricingDeviation::: END INVOKATION ********quNew.Status---->'+quNew.Status );

Please could someone suggest what's going wrong here in the code snippet?

An early response on this will be much appreciated.


Hey SandboxHey Sandbox
As per above statement, it should work perfectly. But, sometimes problem with some white space characters causing this. Mostly it will be problem with Copy and Paste strings from other documents.
Can you please check with typing Status value manually in your debug statement.
Hi Ray,

One possible issue could be, if the status field is a picklist value, then check the api name of the picklist value, some times they are not the same as the picklist label and might be the issue.

Worth a try
om gupta(sfdc)om gupta(sfdc)
hi either we lowercase all the string both of the side and trim also . hope that help