Link to home
Start Free TrialLog in
Avatar of mahmood66
mahmood66Flag for United Arab Emirates

asked on

How to handle "No Checkout Authority could be found for PO" Error Message in SQL Server?

Dear, I have written a trigger, when user voilates trigger gives proper Error Message, but user need to close that PO and reopen it to make it correct. if user does not re-open the PO. he gets the error which is in attached file.
trigger code is given eblow.
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER TRIGGER [POSOProcessing]  
   ON  [dbo].[InvNum]
   AFTER UPDATE

AS
      SET NOCOUNT ON;
Begin
      If exists(select * from _btblInvoiceLines      Where iInvoiceID in ( Select AutoIndex From Inserted) and fUnitpriceincl >1000)
      Begin
            RAISERROR ('Enter Price for KG',16,1)
      End
End


set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go

ALTER TRIGGER [POSOProcessing]  
   ON  [dbo].[InvNum] 
   AFTER UPDATE 
	
AS 
	SET NOCOUNT ON;

Begin
	If exists(select * from _btblInvoiceLines	Where iInvoiceID in ( Select AutoIndex From Inserted) and fUnitpriceincl >1000)
	Begin
		RAISERROR ('Enter Price for KG',16,1)
	End
End

Open in new window

Check-out-Authority.bmp
SOLUTION
Avatar of Lara F
Lara F
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mahmood66

ASKER

Dear, i cannot do at UI level, because the source code we are not having, that's why i am trying to ristrict using trigger.
"Even if user gets error message all updated on a table will be already done" ( your are right but when my statement RaisError executes it rollbacks the transaction so my database is not save the wrong data).
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
with the help of experts idea, i have done.