+ Start a Discussion
Ashish Kumar YadavAshish Kumar Yadav 

how to get record type based on condition hard coaded record type?

Hello Team ,

I am facing issue not getting the record type in soqlQuery
User-added image

System.debug('------------>'+SchemeApplicablefor);
        System.debug('------------>'+samid);
        Set<String> RTNames = new Set<String>();
        
        if(SchemeApplicablefor == 'Distributer'){
            RTNames.add('India SND');
            RTNames.add('Brand W');
            RTNames.add('H&H Modern Trade Distributor');
            RTNames.add('H&H Traditional Trade Distributor');
        }
        if(SchemeApplicablefor == 'Retailer'){
            RTNames.add('H&H Modern Trade Retailer');
            RTNames.add('H&H Traditional Trade Retailer');
            RTNames.add('India SND Retailer');
            RTNames.add('Brand W Retailer');
        }
        if(SchemeApplicablefor == 'Both'){
            RTNames.add('India SND');
            RTNames.add('Brand W');
            RTNames.add('H&H Modern Trade Distributor');
            RTNames.add('H&H Traditional Trade Distributor');
            RTNames.add('H&H Modern Trade Retailer');
            RTNames.add('H&H Traditional Trade Retailer');
            RTNames.add('India SND Retailer');
            RTNames.add('Brand W Retailer');
        }
        
        String soqlQuery = 'SELECT Id, Name, RecordType.Name FROM Account where RecordType.Name in:RTNames';
        System.debug('soqlQuery@@'+soqlQuery);

Please help me to solve the issue.
Dushyant srivastava 8Dushyant srivastava 8
String soqlQuery = 'SELECT Id, Name, RecordType.Name FROM Account where RecordType.Name in:RTNames';
System.debug('soqlQuery@@'+ Database.query(soqlQuery));

OR

System.debug('soqlQuery@@'+ [SELECT Id, Name, RecordType.Name FROM Account where RecordType.Name in:RTNames]);