You need to sign in to do that
Don't have an account?
Ravindar Admin
How to fill a field value from another field in same object before the record is saving in visualforce page?
I created a Visualforce page with custom object fields.
I have date field(date_of_birth__c) & Number field(Age__c).
I am looking to fill the Age__c value before the record is saving into the database.
I can take formula field to calculate the value. But If the date_of_birth__c does not enter, so able to enter age__c manually so I took the age__c field as Number.
I have date field(date_of_birth__c) & Number field(Age__c).
I am looking to fill the Age__c value before the record is saving into the database.
I can take formula field to calculate the value. But If the date_of_birth__c does not enter, so able to enter age__c manually so I took the age__c field as Number.
Just as Prady told, its risky to do date calculation in the client side. Hence did not do the age calculation in
Javascriptinstead did it in the Apex to avoid locale issue. I called the Apex method which calculates the age on the onchange of the Date of Birth field and via Remote Actions. The method returns the Age and then I populate it in the Age textbox using jQuery.Apex Controller
Visualforce
All Answers
But be vary the date is tricky field, The date field on the object will chnage its format in the VF page based on the user locale. You will have to take this also into consideration.
Thank you
Pradeep
Just as Prady told, its risky to do date calculation in the client side. Hence did not do the age calculation in
Javascriptinstead did it in the Apex to avoid locale issue. I called the Apex method which calculates the age on the onchange of the Date of Birth field and via Remote Actions. The method returns the Age and then I populate it in the Age textbox using jQuery.Apex Controller
Visualforce