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
heguangmheguangm 

best way to auto-populate fields calling javascript functions in edit form?

I have three custom fields for one built-in object say ObjA. I would like to fiell Custom Field C when end-user changes values of custom field A and/or B in the edit form of ObjA, before the object is saved.

 

I will call javascript function to do that.

 

What is the easiest way to do this? I am new to Salesforce. I expect something like this: create a javascript file with my functions, associate it with the object edit form (maybe some customization to the object/form).

 

Thanks,

Ritesh AswaneyRitesh Aswaney

It would be easier just to have a workflow which sets the value on the dependant field based on the value of the controlling field.

The values would be set before they are saved, so unless it is a requirement to see the visual change in values whilst the user is filling in values, a workflow is more desirable.

 

Also consider dependant picklists, if the values are fixed rather than free text.

heguangmheguangm

Appreciate your quick response.

 

I do require to see the new value applied to the custom field C on the edit form as soon as any changes made to the dependent fields.

 

The trigger/workflow not ideal is obvious. The picklist does not work, the custom field C's value is arbitrary not from a fixed set of value.

 

Any new idea?

 

I am really looking for the best way to insert a field control change event handler. This is easy in normal web page development.

Ritesh AswaneyRitesh Aswaney

prolly have a visualforce section in your page, which has embedded javascript to toggle the values - this is if you're looking to leverage stuff off the standard salesforce layout.

 

if you're open to customsiation, then prolly visualforce the whole page

heguangmheguangm

Could you explain more on your recommendation as I am a new guy here?

 

prolly have a visualforce section in your page, which has embedded javascript to toggle the values - this is if you're looking to leverage stuff off the standard salesforce layout.

Ritesh AswaneyRitesh Aswaney

Scratch that, actually I dont think you can have Visualforce sections in Edit mode, not just yet anyway.

 

SO your (possibly only) option is to have a custom visualforce page (custom development), in which you can embed javascript to do your field setting trickery.

 

Visualforce is Salesforce's custom visual component framework, a little bit like jsp or asp if you've done Java or .NET programming.

AdyAdy

Use a homepage sidebar component. Insert your js code into it. invoke the code for your page and it will work.