Display status change to user on doc.save()

Hi there,

testing the meeting app …

on apy.py when successfully sent invitation to attendees, status is changed to "Invitation Sent" and meeting doc saved, on front end status is not changed until page refresh.

Any hint on how to change it? I’ve tried to change on callback using:

frappe.model.set_value(cdt, cdn, "status", r.message);

where r.message = meeting.status returned from apy.py file, but status will change to Not Saved instead of “Invitation Sent”.

Thx

Hi @JoEz,

Above code will only set the status and to update you need to save it. To tackle this issue you have two options
Either set the status in apy.py file using obj.db_set(“status”, “Invitation Sent”) or

frappe.model.set_value(cdt, cdn, "status", r.message);
frm.save() 

Thanks

1 Like

@rohit_w

Thx for the hint, i tried frm.doc.save() and doesn’t exist :grin: …will try both solution.

Hi @rohit_w,

Cant get this to work, at least it doesn’t change:

to

While in the db is correctly saved …i’ll try on js file …

update: using

frappe.model.set_value(cdt, cdn, "status", r.message);
frm.save()

it works …

ok …ended up using using in api.py:

frappe.sendmail(
    recipients=[recipient.attendee for recipient in meeting.attendees],
    sender=frappe.session.user,
    subject=meeting.title,
    message=meeting.invitation_message,
    reference_doctype=meeting.doctype,
    reference_name=meeting.name
)
meeting.status = "Invitation Sent"
meeting.save()

and in .js

send_emails: function (frm, cdt, cdn) {
	if (frm.doc.status === "Planned") {
		frappe.call({
			method: "meeting.api.send_invitation_emails",
			args: {
				meeting: frm.doc.name
			},
			callback: function (r) {
				if (r.message !== "Planned") {
					frm.reload_doc();
				}
			}
		});
	}
},

Not sure if it’s best way …but works properly …

Thx again for help …u can close the post …