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
DamionAllenDamionAllen 

Visualforce with Recordtype default picklist values

I am having an issue where I can get the picklists to filter etc in my custom VF (assign the recordtype to the object) but none of the fields are utilizing the default values set in the recordtype if I display the field. If I do not display the field, the defaults work just fine. Anyone know if or how this should work? is there anything special I need to do to make it happen?

Best Answer chosen by Admin (Salesforce Developers) 
DamionAllenDamionAllen

Ok, I was able to default the picklist valies utilizing the values in recordtype y using the following

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_fields_describe.htm

 

there is a "newSObject" method that we pass in the Record Type ID and set a boolean value to "Set Defaults"

 

Id recType = QuickCall_Helper.GetRecordTypeId('Call_Log__c',config.CalllogRecordType__c);

if(recType!=null){
        objCallLog = (Call_Log__c)Call_Log__c.sObjectType.newSObject(recType, true);
}

 

 

All Answers

CloudPower1CloudPower1
If you are trying to assign recordtype to the object record then try assigning the record type based on developer name field from record type Object
DamionAllenDamionAllen

 


CloudPower1 wrote:
If you are trying to assign recordtype to the object record then try assigning the record type based on developer name field from record type Object


 

Not sure I understand what you are asking. The record type works in every way except for setting the default picklist values when I present that field to the user. You cant assign a record type to an object using only the Developer name, you query for the record type by the name etc... 

DamionAllenDamionAllen

Ok, I was able to default the picklist valies utilizing the values in recordtype y using the following

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_fields_describe.htm

 

there is a "newSObject" method that we pass in the Record Type ID and set a boolean value to "Set Defaults"

 

Id recType = QuickCall_Helper.GetRecordTypeId('Call_Log__c',config.CalllogRecordType__c);

if(recType!=null){
        objCallLog = (Call_Log__c)Call_Log__c.sObjectType.newSObject(recType, true);
}

 

 

This was selected as the best answer