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
SantoSanto 

Can a custom field be use in the where clause of a SOQL.

//Java Code , Windows 2000

     QueryResult qr;

     String sql_where = " where customefield1 = 'Y' "
     query = "Select id, name, customfield1, customfield2 from opportunity " + sql_where;
     qr = sforce.query(query);

     When I used a custom field in the where clause, the query return nothing.

DevAngelDevAngel

Hi Santo,

You absolutely can use a custom field as criteria in a where clause.  You just need to reference the field properly.

In the UI a custom field might be defined as:

Name: customfield

Label: custom field

From the describe call the field would be shown as:

Name: customfield__c

A valid SOQL where clause could be

Select Id From Contact Where customfield__c = 'New value'