+ Start a Discussion

calling record type id into another class

Hi All,
I am new to salesforce.
I have defined recordtypeid in one class. I want to to call this id in SOQL query of another class. like in where condition of SOQL query.
How to this. This is my sample code.
public class A{
public static final Id RT_Parent = getRecordTypeId('MarketingRT', 'Obj1__c');
public class B{
Obj1__c o=[SELECT Id FROM obj1__c WHERE  RecordTypeId =: ]

I want to declare recordtype id in class A and I want to call it in class B. How to do this?

Please help me

Thank you in Advance
Best Answer chosen by SFDC ADM 7
Shruti SShruti S
The query in class B would return a List of records hence make sure that you initialise a List of Obj1__c to fetch the records. And to get the record id in class B, you can write code as below -
public class B{
    public List<Obj1__c> o = [ 
        SELECT  Id 
        FROM    obj1__c 
        WHERE   RecordTypeId =: A.RT_Parent
If the above code doesnt work, please let me know where you have defined the getRecordTypeId method.