Skip to content

Instantly share code, notes, and snippets.

@GreyMark7650
Created April 24, 2013 16:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GreyMark7650/5453382 to your computer and use it in GitHub Desktop.
Save GreyMark7650/5453382 to your computer and use it in GitHub Desktop.
My code for script - next_id is a button defined on the form. I modified your code to return any records (like '%') and to simply assign this value to the new value without any manipulation. I still get a blank though. Any further ideas?
cur_frm.cscript.next_id = function(doc)
{
doc.item_code = "";
switch(doc.item_group)
{
case "100-XXXXXX - RESISTOR":
doc.item_code = "100-";
break;
case "110-XXXXXX - CAPACITOR":
doc.item_code = "110-";
break;
default:
doc.item_code = "010-";
}
wn.call(
{
method: "webnotes.widgets.query_builder.runquery",
args:
{
"query":"SELECT `tabItem`.name \
FROM `tabItem` WHERE `tabItem`.name like '%' \
ORDER BY name desc limit 1"
},
callback: function(r)
{
// returned last value
last_id = r.values[0][0]
var new_id = last_id;
cur_frm.set_value("item_code", new_id);
}
});
//doc.item_code += "000000";
refresh_field("item_code");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment