When a user tries to add a new item and save the document, a message is shown saying, ‘Do you want to add a price?’. After adding the price and trying to save again, I want to show another message saying, ‘Do you want to add stock?’. However, both messages are not working correctly. In which event should I perform this operation? I am doing this in a client script.
When i enterd the item and try to save a message will appear "if you want to add the price when i click continue it scroll to Price field .
After entering the price and trying to save the document again, I want to show another message saying ‘Do you want to add stock?’ with Yes or No options. Currently, both messages appear at the same time. In which event should I perform this? . Is this possible? Please help.
Hi, @PRaful_9898
You need to create a client script for ITEM Doctype.
Basically you will write something which target the fields like stock, item price, check the correct name by in the cuztomize form–> Item.
Here is an example which i use.
frappe.ui.form.on('Purchase Invoice', {
before_workflow_action: (frm) => {
// Default to validated unless proven otherwise
let is_validated = true;
if (frm.selected_workflow_action == "Send for Re-Submission") {
if (frm.doc.workflow_state == "Submitted for PC Approval" && !frm.doc.rejected_reason_by_project_coordinator) {
frappe.throw("Please mention Rejected reason by Project Coordinator !");
is_validated = false;
} else if (frm.doc.workflow_state == "Submitted for Accounts Approval" && !frm.doc.reject_reason_by_accounts_manager_invoice_checker) {
frappe.throw("Please mention Reject Reason by Accounts Manager
(Invoice Checker) Reason !");
is_validated = false;
} else if (frm.doc.workflow_state == "Submitted for CD Approval" &&
!frm.doc.reject_reason_by_md_user) {
frappe.throw("Please mention Reject Reason by CD User Reason !");
is_validated = false;
}
In this when a user resubmit a invoice a pop-up box appears which tells them to 1st enter the re-submit reason and save it.
So based on this you need to create a script for yourself.
Hope it helps !
Thank you
1 Like