+ Start a Discussion
MiddhaMiddha 

Querying Formula Field - LEFT()

Hi,

 

I have created a formula field on Account to get the prefix from Account Number. I have account number in form like "1234-5678". I created a new formula field 'Account Number Prefix' which gets me "1234" from this Account Number.

 

formula: LEFT( AccountNumber,FIND("-", AccountNumber,0)-1)

 

This shows correct results within Salesforce instance. But when i go and Query this field from Apex explorer it doesnt shows me any value in this formula field. i tried replacing this formula to:

TEXT(FIND("-", AccountNumber,0))

 

and it shows me the correct result.

 

I am also querying many other formula fields which are giving me correct result in my queries. Is there something wrong in the way i am using "LEFT()"?

 

Please advise.

Best Answer chosen by Admin (Salesforce Developers) 
md1md1
Just use Find("-", AccountNumber) instead of Find("-", AccountNumber,0) and you should be all set!

All Answers

MiddhaMiddha

Actually it seems that the issue is with FIND and not LEFT, so the FIND is not workin. As i specified in my post earlier, the results of FIND are not correct.

 

I replace the value of FIND with a number i.e. 4 and i am getting the formula value in Query. FIND seems to have some issue.

md1md1
Just use Find("-", AccountNumber) instead of Find("-", AccountNumber,0) and you should be all set!
This was selected as the best answer