I am attempting to post a comment on a Mat Req from a supplier quotation on validate, using the following code.
frappe.ui.form.on("Supplier Quotation", {
validate: function(frm, cdt, cdn) {
var d = locals[cdt][cdn];
var mr = [];
frm.doc.items.forEach(function(d) {
mr.push(d.material_request);
});
for (var i = 0; i < mr.length; i++) {
frappe.call({
"method": "frappe.client.set_value",
"args": {
"doctype": "Material Request",
"name": mr[i],
"value": cur_frm.timeline.insert_comment("Comment", "My Comment")
}
});
}
}
});
It is giving me the following errors:
POST http://[SERVERADDRESSREDACTED] 500 (INTERNAL SERVER ERROR)
send @ jquery.min.js:4
ajax @ jquery.min.js:4
frappe.request.call @ desk.min.js:138
frappe.call @ desk.min.js:134
validate @ file:61
(anonymous) @ form.min.js:254
(anonymous) @ form.min.js:254
map @ jquery.min.js:2
trigger @ form.min.js:254
_f.Frm._save @ form.min.js:92
(anonymous) @ form.min.js:86
desk.min.js:150 Traceback (most recent call last):
File "/home/frappe/frappe-bench/apps/frappe/frappe/app.py", line 55, in application
response = frappe.handler.handle()
File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 19, in handle
execute_cmd(cmd)
File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 36, in execute_cmd
ret = frappe.call(method, **frappe.form_dict)
File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 890, in call
return fn(*args, **newargs)
TypeError: set_value() takes at least 3 arguments (3 given)
jquery.min.js:4 POST http://[SERVERADDRESSREDACTED]/ 417 (EXPECTATION FAILED)
send @ jquery.min.js:4
ajax @ jquery.min.js:4
frappe.request.call @ desk.min.js:138
frappe.call @ desk.min.js:134
insert_comment @ form.min.js:420
validate @ file:66
(anonymous) @ form.min.js:254
(anonymous) @ form.min.js:254
map @ jquery.min.js:2
trigger @ form.min.js:254
_f.Frm._save @ form.min.js:92
(anonymous) @ form.min.js:86
desk.min.js:150 Traceback (most recent call last):
File "/home/frappe/frappe-bench/apps/frappe/frappe/app.py", line 55, in application
response = frappe.handler.handle()
File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 19, in handle
execute_cmd(cmd)
File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 36, in execute_cmd
ret = frappe.call(method, **frappe.form_dict)
File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 890, in call
return fn(*args, **newargs)
File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/form/utils.py", line 57, in add_comment
doc.insert(ignore_permissions=True)
File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 222, in insert
self.run_post_save_methods()
File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 771, in run_post_save_methods
self.run_method("on_update")
File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 654, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 882, in composer
return composed(self, method, *args, **kwargs)
File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 865, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 648, in <lambda>
fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/communication/communication.py", line 75, in on_update
update_comment_in_doc(self)
File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/communication/comment.py", line 79, in update_comment_in_doc
update_comments_in_parent(doc.reference_doctype, doc.reference_name, _comments)
File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/communication/comment.py", line 146, in update_comments_in_parent
raise ImplicitCommitError
ImplicitCommitError
Any suggestions?