Is it possible to update and save another document with a client side custom script?
Should be possible using frappe.client.set_value
frappe/client.py at develop · frappe/frappe · GitHub
2 Likes
I’ve attempted to use this, I made the following script:
frappe.ui.form.on("Testbed DocType A", {
button: function(frm) {
frappe.call({
"method": "frappe.client.set_value",
"args": {
"doctype": "Item",
"name": frm.doc.item,
"fieldname": ["workflow_state"],
"value": frm.doc.status
}
});
}
});
It gives me the following error on execution:
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 879, in call
return fn(*args, **newargs)
File "/home/frappe/frappe-bench/apps/frappe/frappe/client.py", line 62, in set_value
if df.fieldtype == "Read Only" or df.read_only:
AttributeError: 'NoneType' object has no attribute 'fieldtype'
frappe.ui.form.on("Testbed DocType A", {
button: function(frm) {
frappe.call({
"method": "frappe.client.set_value",
"args": {
"doctype": "Item",
"name": frm.doc.item,
"fieldname": "workflow_state",
"value": frm.doc.status
}
});
}
});
This works! Thanks @rmehta, @max_morais_dmm
1 Like