You need to sign in to do that
Don't have an account?
Henrique Rodrigues
How to insert values in a object with RecordType?
Hello everyone, i'm coding a test class and I have a 'insert' in the account object that have a RecortType, how can I reference the Record Type to insert?
The error is: System.DmlException: Insert failed. First exception on row 0; first error: INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST, bad value for restricted picklist field: Warehouse: [Type2__c]
The error is: System.DmlException: Insert failed. First exception on row 0; first error: INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST, bad value for restricted picklist field: Warehouse: [Type2__c]
Account ac = new Account(); ac.Name = 'Account'; ac.Type2__c = 'Warehouse'; ac.Country2__c = ct.Id; ac.City__c = city.Id; ac.Oracle_Code__c = '1'; insert ac;
Get Record type using scema
Id recordTypeId = Schema.SObjectType.OBJECT_NAME.getRecordTypeInfosByName().get('RECORD_TYPE_NAME').getRecordTypeId();
Let us know if this will help you