How to write change event on item code without affecting the existing change events

Hello, I am trying to write a change event on sales order item table, for item_code field. I want to fill an another custom child table based on the selected item. but currently what happening is if I write cscript.item_code then the existing functionality for fetching name, description, qty etc does not work. so how can i write script to extend the existing function along with my custom function.

1 Like

It will help if you show your code.

@tundebabzy thanks for reply, for example in below code i am trying to run cscript on item_code but doing so my code works but the actual events does not get trigger.

cur_frm.cscript.item_code = function (doc,dt,dn){{
args: {
‘item_code’ : locals[dt][dn][‘item_code’]
callback: function(r ) {
if (r.message) {


I know its late but it may help for someone else.

One way to do this is to override whitelisted method erpnext.stock.get_item_details.get_item_details in of your custom app.

override_whitelisted_methods = { "erpnext.stock.get_item_details.get_item_details" : "" }

In your .py custom script file add this code

def custom_get_item_details(args):

'that run standard event.
from erpnext.stock.get_item_details import get_item_details
out = get_item_details(args)

'Allow you to get data from args.
args = process_args(args)

'Your change event. You can append data to out.

return out

def process_args(args):
	if isinstance(args, basestring):
		args = json.loads(args)

args = frappe._dict(args)

return args