Frappe.db.set_value in custom script

Dear Team,

I want to ask you how to use “frappe.db.set_value(cdt, cdn, “amount”, “100”);”
this in a custom script of Doctype.

I am using it but it is giving Document has been modified error when i save the doc and when I refresh its values were not getting saved because of this error.

Kindly provide the solution.

Regards,
Vishakha