function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
vamsi varmavamsi varma 

How can we skip Record Type Selection Page while creating new contact

I have four types of account record types and i have three types of contact record types.

while creating a new contact the record type selection page must be skipped and the record type for contact must be based on account record type.
How this can be possible any suggestions ?
I have a logic to get contact record type id based on account record type id.
Can anyone help to solve this issue using visualforce page.

Thanks in advance
Vamsi

Ishwar ShindeIshwar Shinde
Hi Vasmi,

Please add following parameter to the URL of Contact creation page - 
RecordTypeId=RecordTypeIdWhichYouWantToSet

for e.g. Your url will look like - 
https://ips007-dev-ed.my.salesforce.com/003/e?RecordTypeId=RecordTypeIdWhichYouWantToSet

Thanks and Regards,
Ishwar 

Please mark this as best answer if it solves your problem.
Ishwar ShindeIshwar Shinde
Code Snippet - 

ID rtId = ContactRecordTypeId;
PageReference p = new PageReference('/003/e?RecordType='+rtId);
p.setRedirect(true);
return p;
vamsi varmavamsi varma

But this is good in sandbox , we cannot hardcode recordtype id and i have three types of record ids , i cannot go on edit them for each and every action right.

And id changes in production so this is not the right way.

Is there any other way which suits my problem exactly using visual force.

Thanks ,
Vamsi Varma

Ishwar ShindeIshwar Shinde
Hi Vsami, You can make query to RecordType object. DeveloperName field is unique and not changes in different environment. Using this you can get the record type id dynamically. For e.g. Select id from RecordType where developerName = 'Contact_RecordType_Name' Thanks, Ishwar Shinde
VineetKumarVineetKumar
Override the new button with a custom VF page, in the VF page have your logic of get the correct recordtype Id (based on account recordtype matching), Make this VF redirect to contact creation page using pageReference.
Also, while over riding remember to check the checkbox to skip the record type selection page.

Let me know if that helped.
vamsi varmavamsi varma

vineetkumar,
i have done that , but when creating new contact from contacts tab, we will not have any default account id , so when we select account in vf page , the page should refresh and work as in previous case i.e.new contact from account page layout.

in the first case i am creating new contact from account page layout and i am able get expected results(contact record type id).please see below image.

                          User-added image

in the second case when i am trying to create new contact from contacts tab we dont have account name here , so when we select account name in the field the vf page should refresh and contact record type should be automatically populated.

User-added image


can anyone help me in this issue , its very urgent.

Thanks in advance,
Vamsi Varma.

VineetKumarVineetKumar
On the Account Name field, use the onChange attribute of the input tag, which calls the controller method, that will do the record type match and set it for you, and reRender the section 
.
Can you share your code here?