JoEz
September 29, 2016, 8:55am
1
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
rohit_w
September 29, 2016, 11:06am
2
Hi @JoEz ,
JoEz:
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”.
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
JoEz
September 29, 2016, 11:18am
3
@rohit_w
Thx for the hint, i tried frm.doc.save() and doesn’t exist …will try both solution.
JoEz
September 29, 2016, 1:58pm
4
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 …