"If" and "Else If" statements

Hey guys,

How would this be handled in frappe?

If field len is 1-5: field nozzle_column = 1
If field len is 2-10: field nozzle column = 2
Otherwise = field nozzle column = Error

Oh man…

First, frappe uses Python (for the server) and Javascript (for the client). Frappe does not use Java at all. I understand you are starting and trying which is commendable, but it sounds really bad and you are less likely to receive help saying those things.

Assuming by your Java reference and by the code that you are trying to write Javascript, your code looks fine except you are missing a ; at the end of the line inside the else. Also, keep in mind that you are assigning the values of “1” and “2” as strings, not numbers. This means that you can not count or do any mathematical operation with them. Assigning “1” is similar to assigning “t” (just a different character) and is very different from assigning a plain 1. I am just starting with ErpNext so I don’t know what exactly you are trying to do but it looks a bit weird.

Thank you for your reply. I understand that frappe doesn’t use this, however I was providing it as an example of what I was trying to ask. I can see how this isn’t helpful, I’ll edit my original post.

frappe.ui.form.on("len", function(frm) { 
  if(frm.doc.len=="1-5") frm.set_value("nozzle_column", 1);
  ..
});
1 Like