ERPNext Foundation ERPNext Cloud User Manual Blog Discuss Frappé* Donate

Document status is shown as Not Saved

customize_form

#1

Hello,

After saving the form, we are changing one of the form field value explicitly using frm.set_value(“current_location”, obj.id).

I have used jquery autocomplete plugin…so in Database side we are storing id field and on form showing city value. so in after_save trigger setting city name again.

Then it shows Document status as ‘Not Saved’… as we have changed the field value.

How to set Document status as ‘Saved’.?

Thanks!


#2

Try frappe.model.set_value()

frappe.model.set_value("Doctype", frm.name, "field_name", "value");


#3

Thanks!

Value can be set on the field using frappe.model.set_value, but still Doc status is shown as Not saved…

Any help?


#4

I think this is because your trigger is after_save which runs after the form is saved. Or maybe you have a script that changes something in the form/doctype after the form has been saved.

Once the doctype detects that a field has been changed AFTER it has been saved, it reverts from Saved to Not Saved. If you want to write a value straight to the database, I suggest creating a python method which will execute via hooks.py.

Use frappe.db.sql in your python script to write the data straight to the database instead of saving it via the front end.

Hope this helps.

Regards,

Hera


#5

Many Thanks @littlehera … I can update cityid using frappe.db.sql in python script…in after_save trigger…

While editing record, I have to show City Name again from cityid… and doctype detects that a field has been changed and it reverts from Saved to Not Saved.

Only want to know that actually is it possible to manage this kind of thing in a single field?..where we are storing value in DB which is other than that we are showing on the form…


#6

Will City Name be stored in the UI? Or do you only need it to be shown/visible but it’s not necessary to store it in the db?

You can change City Name to an HTML field which you can change using javascript.

Also, is it necessary for City Name to be set after save? I think it would be better to set City Name once cityid has been set using cur_frm.add_fetch or frappe.call (if you are coding via js).