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
VSK98VSK98 

GetLabel name using Dynamic Apex

Hi,

I have one SOQL query like 
I want Reocrd Type Label name , Is it possible to get using dynamic apex...........................

Adv Thnx
VSK
Tarun SuriTarun Suri
Sure You can. here you go
 
recordtype leadre = [SELECT DeveloperName,Id,IsActive,SobjectType FROM RecordType where SobjectType='Lead' and DeveloperName='TestRecordtype'  limit 1]


 
Amit Chaudhary 8Amit Chaudhary 8

Some time in code we need to get recordTypeId . For that generally we used SOQL like below :-

Id contRecordTypeId = [Select id from RecordType where sObjectType = 'Contact' and developerName ='NameOfRecordType' ].id ;

You can try below Describe to get record Type Id without SOQL

Id contRecordTypeId = Schema.SObjectType.Contact.getRecordTypeInfosByName().get('NameOfRecordType').getRecordTypeId();

Thanks
Amit Chaudhary
VSK98VSK98
Hi Tarun,

Thanx for your replied, but i dont want it with SOQL here............want with dynamic apex

I have used here but getting error
string strRecType = Schema.SObjectType.Contact.getRecordTypeInfosByName().get('Business').getDeveloperName();

Please suggest me

Adv thnx
VSK