Last active
December 16, 2015 14:59
-
-
Save rmehta/5452216 to your computer and use it in GitHub Desktop.
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.item_prefix = function() { | |
// will be called on change of item_prefix | |
// note: it is important to specifiy tablename.fieldname | |
// in query as permissions are evaluated on this basis | |
// and sql keywords must be in CAPS | |
wn.call({ | |
method: "webnotes.widgets.query_builder.runquery", | |
args: { | |
"query":"SELECT `tabItem`.name \ | |
FROM `tabItem` WHERE `tabItem`.name like '" + doc.item_prefix +"%' \ | |
ORDER BY name desc limit 1" | |
}, | |
callback: function(r) { | |
// returned last value | |
last_id = r.values[0][0] | |
var new_id = /* some id logic */ | |
cur_frm.set_value("item_code", new_id); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment