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
bremmibremmi 

How do I automatically update value in field2 when I enter value in another field1

Hi 

i have two fields in visualforce page, one is manufacture date  field and another one is expired  date field.

when i enter date in manufacture date field, the second field should automatically be incremented by 3 years. is it hole thing  possible using visualforce and apex............?

 

regards

Bremmi

SeAlVaSeAlVa

Do you want it to be updated while the user is editing or once the record is saved?

 

1) When the record is saved:

1.a) Use a workflow rule and a field update action to achieve that.

1.b) Use a trigger (cons: need testing and should be bulk friendly)

1.c) Use apex-code before saving to do that. (cons: need testing and should be bulk-friendly)

 

2) When the record is being edited

2.a) Use Javascript (pros: fast, cons: need to know a little bit of JavaScript)

2.b) Use apex:actionsupport, onchange event and rerender in your visualforce. (cons: it is a little bit slower, as it is executed server-side).

 

Hope this helps. I might have forgotten more options, but at least with this bit, you can make a decision.

APathakAPathak

This can be done using the apex:actionsupport onblur event/onchange event on the manufature date field.