It works for standard objects (like Case here):
1: Case c = new Case();
2: RecordType RecType = [Select Id,SobjectType,Name From RecordType Where SobjectType = 'Case' and Name= 'Quality Alerts (QA)'];
3: c.RecordTypeId = RecType.Id;
And custom objects:
1: Communication__c com = new Communication__c();
2: RecordType RecType = [Select Id,SobjectType,Name From RecordType Where SobjectType = 'Communication__c' and Name= 'Outreach'];
3: com .RecordTypeId = RecType.Id;
No comments:
Post a Comment