Hello,
I am trying to add a button to a custom DocType that I have created.
But the button is always visible to user.
Instead I want to make the button visible only if the Doc is submitted.
How can we check if a Doc is submitted in Client Script?
TIA
Yogi Yang
@YogiYang You can do the checking and then create a custom button through a Client Script.
Hello,
I have created a custom script to add button and it is working.
But I want to show the button only after a user submits a DocType.
TIA
Yogi Yang
@YogiYang You can use the following code:
if (!frm.is_new() && frm.doc.docstatus === 1) {
// create the button
}
!frm.is_new()
checks if the form has been saved or not but doesn’t check if it has been submitted.
The values of docstatus
are:
- Draft (value: 0)
- Submitted (value: 1)
- Cancelled (value: 2)
Hello,
Thanks for your help.
This code works for me.
if (frm.doc.docstatus === 1) {
var start_btn = frm.add_custom_button(__('Start Production'), function() {
frappe.throw(__("This feature is under development"));
});
start_btn.addClass('btn-primary');
}
TIA
Yogi Yang