Insert comment to docType from client side

I am trying to add a comment to Quotation module activity. I tried different commands suggested in other threads but none of it seem to work. I tried doc.add_comment('Comment', text='Test Comment') and I am getting Uncaught TypeError: doc.add_comment is not a function I also tried cur_frm.comments.insert_comment("Comment","My Comment") but comments is undefined property of cur_frm.
I also checked frappe docs but still no luck. What am I missing here?
P.S: I am using a demo instance of ERPNext, if that makes any difference.

frappe.get_doc({
    'doctype': 'Comment',
    'comment_type': 'comment',
    'reference_doctype': 'Quotation',
    'referenc_name': 'Q00001',
    'content': 'My comment',
}).insert()
1 Like

For anyone searching an answer for frappe version 13:
there seems to be two ways of doing this in client side as far as I know.

  1. Calling insert_comment function of Timeline object
cur_frm.timeline.insert_comment('My Comment')
  1. Calling a python API method from JS through HTTP request
frappe.call({
"method": "frappe.desk.form.utils.add_comment",
"args": {
  reference_doctype: frm.doctype,
  reference_name: frm.docname,
  content: 'My Comment',
  comment_email: frappe.session.user,
  comment_by: frappe.session.user_fullname,
                }
            });

Unfortunately the suggestion by @Steven_Athouel didn’t work for me.

1 Like