You need to sign in to do that
Don't have an account?

Record Type
Hi,
I have a visulforce page where I create an Account record and in the Controller I set the RecordType for that record, but when I try to insert the record in the database I recive an error message : Attempt to de-reference a null object.
This is my code:
result.RecordType.Name='Persoane fizice';
insert result;
Can anybody tell me how can i set the recordtype name?
I have a visulforce page where I create an Account record and in the Controller I set the RecordType for that record, but when I try to insert the record in the database I recive an error message : Attempt to de-reference a null object.
This is my code:
result.RecordType.Name='Persoane fizice';
insert result;
Can anybody tell me how can i set the recordtype name?
First get your desired record type id by using the below format,
Mention your object name and record type name in the above syntax.
While inserting account record use like below,
All Answers
you can't directly assign RT name instead need to assign ID. So something like following will work.
//query Record type
RecordType rt = [Select ID from RecordType where Name = 'Persoane fizice']; // can use filter like ObjectName = 'Account' etc..
and then use
result.RecordTypeID = rt.id; // using ID
insert result;
First get your desired record type id by using the below format,
Mention your object name and record type name in the above syntax.
While inserting account record use like below,