2

I am trying to make a query for a recordtype id where the developerName can be different values. I am getting error expecting right square bracket, found 'OR'

Set<Id>oppRecTypeSet = [select id from RecordType
                             where sObjecttype = 'Opportunity' 
                             AND DeveloperName='Max' 
                             OR DeveloperName='Min' 
                             OR DeveloperName='Average' 
                             OR DeveloperName='Median'
                             OR DeveloperName='Mean'];

1 Answer 1

5

Here is the proper construction

List<RecordType>oppRecTypeList = [select id from RecordType
                             where sObjecttype = 'Opportunity' 
                             AND  DeveloperName IN ('Max','Min','Average','Median','Mean')];

Note that I changed the object of the query to return a list of RecordType

If you want a set of IDs, then use this

Map<ID,RecordType> rtIdToRecordTypeMap = new Map<ID,RecordType> {
                   [select id from RecordType
                         where sObjecttype = 'Opportunity' 
                         AND  DeveloperName IN ('Max','Min','Average','Median','Mean')]
};

// rtIdToRecordTypeMap.keyset() returns the set of ids

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .