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
billgreenhawbillgreenhaw 

Default text field value based on record type

I have a text box under Opportunities.  I want to default the value of this based on record type.  Default value might be the account name.

 

What would be the ideal approach for this?  Trigger?  Workflow?  etc..  Since the record isn't saved yet and this should default off of what the Record Type was, I am trying to come up with the best solution.  

 

The default values will be values from the account object...90% of the time simply being the account name.  Account name will populated because I am forcing Opportunites to be created from the Account record.

 

Thanks.

Shashikant SharmaShashikant Sharma

It looks to me that you need a trigger as your default values are coming from Account to Opportunity. But still you can decide on it See this : http://forceschool.blogspot.com/2011/05/hi-all-triggers-are-very-essential-in.html

Ankit AroraAnkit Arora

You can not do this using Triggers as they get fired when you perform any action. When we click on new and you need to pre fill some values (default) then trigger is no way to go with.

 

Now if you want to do this with native screens then you need to pass the values in parameter. You first need to get the Id of the fields by view source, in look up fields there are two including the _lkid. You need to pass the Id of the record in "id_lkid" which you want to be prefilled in reference field by default and name in "id" .

 

Over all what I want to suggest is to pass the values as parameter in URL rather using triggers or workflows.

 

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

billgreenhawbillgreenhaw

So maybe a VisualForce page will be the best way to go?  I cannot use the URL parameters (I forgot about those, so thanks for the info) because it might be different fields used based on the Record Type so I don't think that will work.

 

Thanks again.

Ankit AroraAnkit Arora

If the fields are dynamic in which you need to fill the value then you can do this using visualforce and apex.

 

If the reply helps you then you can mark it as solution so others may get benefit.

 

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page