Custom Script Support

I wrote custom script for restricting the purpose - Material Issue is allowing for only two users such as and in Stock entry document.

frappe.ui.form.on(“Stock Entry”, “validate”, function(frm) {
if ((frm.doc.owner != “” frm.doc.owner != “”) && frm.doc.purpose == “Material Issue”) {
msgprint(“You are Not Allowed to do Material Issue”);
validated = false;

But script is not allowing even for my userid: itself. Kindly help me.

frm.doc.owner != "" || frm.doc.owner != ""

You are missing || (or)

Sorry while copying the code I had missed OR ||, I tried with OR only. It doesn’t work.

Try this way

frappe.ui.form.on(“Stock Entry”, {
validate: function(){
if ((cur_frm.doc.owner != “” || cur_frm.doc.owner != “”) && (cur_frm.doc.purpose == “Material Issue”) {
return frappe.throw(“You are Not Allowed to do Material Issue”);

No, it doesn’t work I am getting a error like Uncaught TypeError: Cannot read property ‘refresh’ of undefined and Uncaught SyntaxError: Unexpected token { . Kindly help us.