Add comment to doctype from js

how can I add comment to a doc from js? (I need to add comment to a doc on its submission, from js). I tried cur_frm.add_comment, cur_frm.cscript.add_comment, doc.add_comment, this.add_comment and none of them were recognized.

1 Like

cur_frm.comments.insert_comment("Comment","My Comment")

2 Likes

Thanks a lot @saurabh6790

@saurabh6790 how about python?

You can do this by writing a whitelisted function . and write code as in below in server side

d = frappe.get_doc(‘Opportunity’, name)
#to add a new comment
d.add_comment(‘Comment’,text=‘Test Comment’)

it will add a new comment ‘Test Comment’ in Opportunity and doc.name=name

2 Likes