I have a workflow setup in Expense Claim, i want that once the document is submitted, this document is shared with a particular user (fixed for all)
I used below server scripts, which didn’t worked, throws issues like “import not found”, “add function not found”, or simply doesn’t work
A) didn’t worked
add(doc.doctype, doc.name, user='ayush@gmail.com', read=1, write=1, submit=1, share=1, everyone=0)
B)
from frappe.share import add
add(doc.doctype, doc.name, user='ayush@gmail.com', read=1, write=1, submit=1, share=1, everyone=0)
C)
def on_submit(self):
frappe.share.add(
self.doctype, self.name, self.assign_to, write=1, submit=1, share=1, flags={"ignore_share_permission": True}
)
D)
import frappe
def on_submit(doc, method):
if doc.workflow_state == 'Verification Pending':
# Share the document with the specified user
frappe.share.add(
doctype=doc.doctype,
name=doc.name,
user='ayush@gmail.com',
read=1,
write=0,
share=0,
everyone=0
)
frappe.msgprint(f"Document shared wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwith ayush@gmail.com")
# Connect to the 'After Submit' event of the Expense Claim doctype
doc_events = {
"Expense Claim": {
"on_submit": on_submit
}
}
Please anyone help, i don’t think it is so tough to write a Server script.