Try ERPNext Buy Support Partners Foundation

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 ?



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 ?


just put following code in particular js file.

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

if( == ‘Company 1’){
}else if( == ‘Company 2’){
}else if( == ‘Company 3’){


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 ?


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