cancel
Showing results for 
Search instead for 
Did you mean: 

How to Block Sales from Other Warehouse

Former Member
0 Kudos

Dear All.

I am new to SAP Business One.

I have a Customer using SAP Business One 9.1 PL05 on MSSQL2012.

Is there a way i can setup Users who can only sell (Invoice) from specific warehouse.

Kind Regards

Joshua

Accepted Solutions (1)

Accepted Solutions (1)

agustin_marcoscividanes
Active Contributor
0 Kudos

Hi

you can modify the Transaction Notification to check all sales documents are using the right warehouse.

if (@document_type = '13' and @transaction_type = 'A')

begin

     if (select count(*) from inv1 where docentry = @list_of_cols_Val_tab_del and whscode <> yourwarehouse) >0

          begin

               set @error = 10

               set @error_message = 'Wrong warehouse in sales invoice'

          end

end

Kind regards

Agustín Marcos Cividanes

Former Member
0 Kudos

Dear Agustin

I have tried to use this code and it is restricting all users to use only one warehouse that is specified as yourwarehouse

what i want is to allow users to only select items only from the default warehouse defined in the default user setup and restict them from selecting items in the other warehouses

Thank you in advance

kind regards

Joshua  Gichuhi

agustin_marcoscividanes
Active Contributor
0 Kudos

Hi

try this SQL statement:

if (@document_type = '13' and @transaction_type = 'A')

     begin

          declare @userid int

          select @userid = usersign from OINV where docentry = @list_of_cols_Val_tab_del

          declare @preferences nvarchar(8)

          select @preferences = DfltsGroup from OUSR where INTERNAL_K = @userid

          declare @whscode nvarchar(8)

          select @whscode = Warehouse from OUDG where Code = @preferences    

          if (select count(*) from inv1 where docentry = @list_of_cols_Val_tab_del and whscode <> @whscode) >0          

               begin              

                    set @error = 10              

                    set @error_message = 'Wrong warehouse in sales invoice'          

               end

     end

Kind regards

Agustín Marcos Cividanes

Former Member
0 Kudos

Hi

I have done that but when i try to create an invoice its outputting this error "Microsoft SQL server native client 11.0 SQL -server error converting data type nvarchar to int (CINF).

Which variables are supposed to be int or nvarchar.

Please help

Kind Regards

Joshua Gichuhi

agustin_marcoscividanes
Active Contributor
0 Kudos

Hi

try this code:

if (@object_type = '13' and @transaction_type in( 'A', 'U'))    

begin         

     declare @userid int         

     select @userid = usersign from OINV where docentry = @list_of_cols_Val_tab_del         

     declare @preferences nvarchar(8)         

     select @preferences = DfltsGroup from OUSR where INTERNAL_K = @userid         

     declare @whscode nvarchar(8)         

     select @whscode = Warehouse from OUDG where Code = @preferences             

     if (select count(*) from inv1 where docentry = @list_of_cols_Val_tab_del and whscode <> @whscode) >0                        

          begin                                 

               set @error = 10                                 

               set @error_message = 'Wrong warehouse in sales invoice'                        

          end    

end

Kind regards

Agustín Marcos Cividanes

kothandaraman_nagarajan
Active Contributor
0 Kudos
Former Member
0 Kudos

Hi Agustin

Thanks

it worked  perfectly well.

Again thank you very much

Kind Regards

Joshua Gichuhi

Answers (1)

Answers (1)

former_member228513
Participant
0 Kudos

You can set user wise default warehouse.

Go To

Administration --> Setup --> General --> User Defaults --> Defaults

and after that, you have to link that user default into Users.

If you want to block other warehouses for users, we can use store procedures.

Regards

Halik

Former Member
0 Kudos

Thanks i have set the user defaults and linked them to users and that's fine ,now what i would like is allow the users to create sales order , deliveries and invoice only from the default warehouse set in user default setting and not any other warehouse.

please help