+ Start a Discussion

Pre populating field values using URL over ride and record type



I have a custom object named 'Process_Unit__c' :

1) The user clicks on the Process unit tab.

2) Then clicks on the 'New' button and goes to record type selection and selects the record type.

3)  then he goes and creates a new record, when the new record shows up i want to populate a default value named "Please do not type here" in a mandatory field called 'process unit name' and make it read only is this possible?


I did try it but i am not able to override the new button of the object it self any idea of how this  can be done or should i use a apex class and trigger to populate this default value in the field in the edit mode:


I did this URL over ride, but i am able to put this button in the page layout and this is visible in saved mode only, i am not able to override the 'New' button with button i created:




Help ias higly appreciated.



To override the new button you need to use VF page and a controller. Visit this link and if you still are not able to get it... let me know.




I dont want to use a VF page is there any other method to do this, reason being i have short time line and the page is really very long with reccord types.

Saurabh DhobleSaurabh Dhoble

A. You need to override the "New" button - you can do this from the "Buttons & Links" section for the object.

B. You need to pass the default value for your field in the URL - cannot make it read-only from the URL, but you can definitely pass in the value.


Refer to this series of posts for details - http://writeforce.blogspot.com/2012/12/prepopulating-fields-using-url-hacking.html

Shreyas Shah 9Shreyas Shah 9


This will help you with  auto populate filed with reporttype and the populate record on new create page. 

global static string getPrefixID(){
    return OBJECT_API_NAME.sObjectType.getDescribe().getKeyPrefix();
global static string getObjectId(){
    FieldDefinition listofMetadataPrj =[SELECT QualifiedApiName,DurableId,EntityDefinitionId,Id,Label FROM FieldDefinition WHERE EntityDefinition.QualifiedApiName = 'OBJECT_API_NAME' and QualifiedApiName ='FIELD_API_NAME'];         
           string completeField = listofMetadataPrj.DurableId;
           string[] finalstr =completeField.split('\\.');
            string ObjectId = finalstr[0]; 
           return ObjectID;
global static string getDurableIdforField(){
        FieldDefinition listofMetadataPrj =[SELECT QualifiedApiName,DurableId,EntityDefinitionId,Id,Label FROM FieldDefinition WHERE EntityDefinition.QualifiedApiName = 'OBJECT_API_NAME' and QualifiedApiName ='FIELD_API_NAME'];          
               string completeField = listofMetadataPrj.DurableId;
               string[] finalstr =completeField.split('\\.');
                string DurableIdforField = finalstr[1]; 
               return DurableIdforField;
VF page - JS function (call on button action)
 function Record(PrefixID,DurableIdforField,RecordId,RecordName,ObjectID){
    var baseUrl="https://"+ document.domain +"/setup/ui/recordtypeselect.jsp?ent="+ObjectID+"&retURL=/"+PrefixID+"/o&save_new_url=/"+PrefixID+"/e&retURL=/"+PrefixID+"/o&CF"+DurableIdforField+"="+RecordName+"&CF"+DurableIdforField+"_lkid="+RecordId;
    if ((typeof sforce != 'undefined') && sforce != null) {
    } else {
        window.open(baseUrl ,'_blank');

Hi Santro,

Now URL hack is supported in Lightning Experience. You can override Record type as well and can set default RecordType and set other fields. Check below post for detail and code sample: