Created
April 24, 2013 16:14
-
-
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?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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