0

In Account for Recordtype Company i have to give two different names for a test class on account trigger? How to do that ?

Account accobj = new Account();
accObj.RecordType.Name = 'SomeName';
  • 1
    How/what are you running here? and are you receiving any specific error message? – Simon Lawrence Jul 23 '14 at 12:17
3

you have to query the RecordType using the developer/api name and assign the id of the record type to the records RecordTypeId field..

RecordType rt = [Select Id from RecordType where DeveloperName = 'YourRecordTypeName'];
Account accobj = new Account();
accObj.RecordTypeId = rt.Id;

there should be some previous answers which can give you more details..

here's one i found : Creating a new record with giving record type

| improve this answer | |
1
 Account accobj = new Account();
 accObj.RecordTypeId = 'Id of SomeName';
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.