Skip to content

Instantly share code, notes, and snippets.

View GreyMark7650's full-sized avatar

Mark Webster GreyMark7650

  • Ireland
View GitHub Profile
@GreyMark7650
GreyMark7650 / gist:5494306
Created May 1, 2013 08:21
Client side script to hide a button
cur_frm.cscript.custom_refresh = function(doc)
{
//alert(doc.__islocal ? 0 : 1);
cur_frm.toggle_display("next_id", doc.__islocal ? 1 : 0);
}
@GreyMark7650
GreyMark7650 / gist:5459251
Created April 25, 2013 12:10
A script for erpnext to generate the next item ID in the specified product group.
cur_frm.cscript.next_id = function(doc)
   {
   doc.item_code = "";
   var pattern = "";
pattern = doc.item_group.substring(0,4)+'%';
var query = "SELECT `tabItem`.name FROM `tabItem` WHERE `tabItem`.name LIKE '" + pattern + "' ORDER BY name desc limit 1";
wn.call({
   method: "webnotes.widgets.query_builder.runquery",
@GreyMark7650
GreyMark7650 / gist:5453382
Created April 24, 2013 16:14
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":