function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Deepu2123Deepu2123 

Need to query the length of the fied

Hi Devs,

I am facing the issue in Query.Contacts with NPN numbers that are not null and have less than 10 digits

Select Id,Name,NPN__c FROM CONTACT WHERE NPN__c != null AND NPN__c.Length()<10

NPN__C = Text Fied
.
Raj VakatiRaj Vakati
You can do it simmple way .. 

create a new fomrual to get the length as shown below
 API Name : NPN__Len__c
IF(ISBLANK(NPN__c ), 0, LEN(TRIM(NPN__c )))
Use this in SOQL 
Select Id,Name,NPN__c FROM CONTACT WHERE NPN__c != null AND NPN__Len__c<10
 
Bhargavi TunuguntlaBhargavi Tunuguntla
Hi charan :


Try the below query:
 
SELECT Id,name,phone FROM contact WHERE phone!=null and (NOT phone LIKE '__________')

use 10underscroes to check whether phone contains 10characters or not.

Hope this will be helpful.
 
Jolly_BirdiJolly_Birdi
Hello @charan madugula

Query would be like this:
Select Id,Name,NPN__c FROM CONTACT WHERE NPN__c NOT like '__________%' 

Please mark this as best answer if you find it positive.

Thanks 
Jolly Birdi