0
votes

I have an object with many record types, and I need to populate some fields on it whenever it is created.

For example, I have an object called "CustomObj" with a field called "CustomF" with these 2 Record Types "RecType1" and "RecType2".

On the creation of a new "CustomObj" I need to populate the field the "CustomF" by "Hello" when the record type is "RecType1" and by "Bye" when the record type is "RecType2"

Can I do that using the URL Hacking or I have to create 1 visualforce page to select the record type then redirect to the standard page with the values to populate this field or there is another approach?

What is the best practice?

How can I know the RecordType selected from the url itself ?

Thank you.

3

3 Answers

0
votes

You can do this by an Workflow Rule. Go to Setup->Create->Workflow & Approvals. Than u can choose your object on which u want to set up the workflows. Most of the part should be straightforward since all the steps are well documented.
So one rule would be like: If Record Type == RecType1 than fill in Field XY with value ABC

0
votes

I see. This is also possible. Go to the object and than your field you want to fill in the value. Click on edit and use the formula editor. You can use a rule like

IF( $RecordType.DeveloperName = 'RecType1', 'Value for this', '')

for the default value

0
votes

Salesforce does not provide an option to override "continue" button on record type selection page. but you can override "new" button. So you can do the following

  1. Override "New" button to move to a record type selection page, which will be a custom vf page (use radio buttons, description etc.).

  2. The submit button (u can name as "Continue", just to imitate) should redirect to the standard page of data entry. But the URL will be custom made.

  3. You can refer to this Blog (Saurabh's Salesforce Blog) - http://writeforce.blogspot.in/2012/12/prepopulating-fields-using-url-hacking.html - for the idea of how the URL hacking can be done as per your need. Here you need to identify the field id and use them in the URL to provide a value to be prepopulated.