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
NaniNani 

Dynamic Default Values

Hi,

 

On the Account object, I have a field called 'Language'. The requirement is to default this field with the logged in users languge.

 

Could someone please help me with the approach?

 

Thanks in advance.

WmWm

If you always want it to be defaulted to the the logged in username you can write a formula field. This will always show the current user language.

Cool_DevloperCool_Devloper

I don't think u can access user's locale (language) in formula field! 

Coming to your requirement, is it a picklist field? Do you want to freeze it or default it? 

If you wanna default (pre-populate) it, then you might have to use an S-Control to do this.

Cool_D 

NaniNani

Thank you for your replies.

Infact, there are 4-5 fields thats needs to be dynamically defaulted from User record.

 

@Cool_Devloper: Yes, it is not possible to access language field from User record. Not just language, there are many fields on User record which cannot be accessed using $User.

 

I had to create a visual page similar to Account Edit page and using some page scripts to default the fields. I'm not sure if this is the best way to do it. I'm very new to Salesforce and could only find this option.

 

Well, I now have a new issue. I'm not able to create apex:inputField for Account Owner and Record Type fields.

 

Any idea on how to do that?

Cool_DevloperCool_Devloper

Yes, that's the way to do it!

If you're not able to use inputFields for owner/recordtypes, then maybe you can create adrop down or a custom lookup and then when you are saving the record, save the selected values in the owner/recordType fields respectively;)

Cool_D 

NaniNani

I just removed the Account Owner (default value-user id) and Record Type from the page. The user will not see the fields while creating the records but will see them as soon as the record is save.

 

Thanks a lot for your support.