You need to sign in to do that
Don't have an account?
Record type data type
Hi all,
I need to insert a values into record type field from Apex code. I saw the data type as (Record Type). How should i insert Into Record Type filed.
I need to insert a values into record type field from Apex code. I saw the data type as (Record Type). How should i insert Into Record Type filed.
Please elaborate on your requirement. If you want to populate the Recordtype on record creation then you can enable that recordtype for that user profile so user can select the proper recordtype as it will be asked before cretaing new record.
If you want to update it, you can go for before update trigger.
Thanks,
Pratik
My Requirement is I want move a record from one custom object another custom object on button click from First object.
In second object Record type is required filed I need to pass value to record type to insert the value into second object, Now I am passing values manually as string to record type But it is not accepting (Error: Compile Error: Illegal assignment from String to RecordType at line 6 column 13).
What is the solution for this.
Working on above code.
Thanks.
Recordtype field will accepts the ID of the record type, hence you would required to query the record type ID as below
ID rtId = [SELECT Id FROM RecordType WHERE sObjectType='Account' AND Name='RT1'].Id;
here sObjectType = Object Name and Name = Record type Name
and then assign the rtId to "Project.RecordType".
Project.RecordType=rtId ;
Thanks,
Sivasankar
Thanks for the replay
I am getting the error (Compile Error: Illegal assignment from Id to RecordType at line 25 column 12).
project.RecordTypeId = rtId;
Please mark the question as resolved if it solves your problem.
Try to convert it as String and assign it.
Hope this will help you, let me know in case any concerns.
Thanks,
Sivasankar.