Automatically select naming series while logged in with different company

Hello All

I have setup 3 companies in ERPNext . I have setup different naming series for different companies. Like :

Company 1 Sales Order : COM1SO
Company 2 Sales Order : COM2SO
Company 3 Sales Order : COM3SO

I have restricted users to specific companies. But while creating sales orders for company 1 user naming series COM1SO get automatically selected. But when Company 2 user is logging in he need to manually select Naming series COM2SO . This is a big hassle and also they are making several mistakes . Is there any way to solve this ?

Thanks

@inventobd,

For this you have to do manually coding in js.

cur_frm.cscript.onload_post_render = function(frm,dt,dn){

// Add Your code here for select naming series

}

Thanks a lot for your answer. I,m not that good with JS. Can you help me a bit on this ?

Thanks

just put following code in particular js file.

cur_frm.cscript.onload_post_render = function(frm,dt,dn){

if(doc.company == ‘Company 1’){
cur_frm.set_value(“naming_series”,“COM1SO”)
}else if(doc.company == ‘Company 2’){
cur_frm.set_value(“naming_series”,“COM2SO”)
}else if(doc.company == ‘Company 3’){
cur_frm.set_value(“naming_series”,“COM3SO”)
}

}

Thanks a lot man . So I need to add custom script for every specific doctype for which I have created naming series ? Can you please just tell me for sales order where I need to put this ? Or I can achieve this by adding this to custom script section in Setup ?

Thanks

wc @inventobd,

Just add the given script for each particular form like sales order in which you have created naming series.

Hello Man Tried the code to both sales_order.js / custom script section but it make sales order blank

it doesn’t work !

try this