Custom Script Support

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

code:
frappe.ui.form.on(“Stock Entry”, “validate”, function(frm) {
if ((frm.doc.owner != “a@pss.com” frm.doc.owner != “b@pss.com”) && 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: a@pss.com itself. Kindly help me.

frm.doc.owner != "a@pss.com" || frm.doc.owner != "b@pss.com"

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 != “a@pss.com” || cur_frm.doc.owner != “b@pss.com”) && (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.