2

I am Using a simple Soql Query Like below:

Set<Id> Testset = new Set<Id>(); 
List <BR_Channel__c> channel = [select id, BR_District__c from BR_Channel__c 
                                  where BR_District__c in : Testset];

Now Here BR_District__c is a text field..

i have various id's stored in Testset but upon Query its not resulting to any Records.

Can we Use set of List directly with text field in where clause of Sooql?

Please Suggest, thanks.

2
  • 1
    What happens when you change Set<Id> to Set<String> ? Commented Feb 12, 2016 at 12:58
  • Why not make BR_District__c an Id field?
    – powlo
    Commented Feb 12, 2016 at 13:03

1 Answer 1

0

Since BR_District__c is text field then use set<String> instead Set<Id>

Set<String> Testset = new Set<String>();
Testset.add('Test1');
Testset.add('Test2');

 List <BR_Channel__c> channel = [select id, BR_District__c from BR_Channel__c 
                                  where BR_District__c in : Testset];

 system.debug('==============channel ===='+channel );
3
  • HI All,Thanks for your promt replies..i have Tried with Using Set of String as Well But Still Sooql query is not returning anything here.. Commented Feb 15, 2016 at 6:52
  • 1
    @PrateekJain issue solved?
    – Ratan Paul
    Commented Feb 17, 2016 at 16:50
  • 1
    Hi Ratan..Sry for Late Reply..Yeah it was my bad that Set of String has worked,thakns for your help.. Commented Feb 18, 2016 at 5:11

You must log in to answer this question.

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