Message Print custom script

I tried use this custom script code

 frappe.ui.form.on("Sales Order Item", {
            	onsubmit: function(frm) {
            		if(frm.doc.projected_qty < 0){
            			frappe.msgprint('Warning');
            	
            		}
            	}
            })

to display warning message to user for stock shortage but it’s not working

Hello,

Try following script, it is working

frappe.ui.form.on("Sales Order Item", "item_code", function(frm, cdt, cdn){
	frappe.after_ajax(function() { 
		var d = locals[cdt][cdn];
		if(d.projected_qty<=0){
			msgprint("Projected Qty is <=0");
		}		
	});
});

This code should put under Sales Order type

please avoid opening multiple threads for the same issue

@ganas
I’m sorry i’ll take care about that