Changing value on form via server side script

Hi,

i wonder how i can change a value in a form when im saving ?

im tried to do it at on_update method but no luck… or i must do it in client side rather than server side ?

Thanks

Add the code in validate method, on_update is called after inserting/updating data into database.

If you want to change the value in on_update, use frappe.db.set_value() method.

what should i do in validate method to update the value on the field ?..i mean what the method should i use

Thanks

just assign the value to the field:

self.fieldname = value

i have already tried that but after saving the filed is not being updated

im doing like this
def on_update(self):
self.booking_value=self.asset_value
val=frappe.get_doc(“Depreciation”, self.depreciation)
self.deprecation_value=val.valueself.asset_value/100
self.counter=val.periode
12
self.last_transaction=self.posting_date

def validate(self):
    self.booking_value=self.asset_value
    val=frappe.get_doc("Depreciation", self.depreciation)
    self.deprecation_value=val.value*self.asset_value/100
    self.counter=val.periode*12
    self.last_transaction=self.posting_date

wow thats works… thanks a lot… :slight_smile: