Skip to Content
0
Dec 07, 2021 at 07:27 AM

Stored Procedure for blocking Draft Returns if a UDF is blank

97 Views

I created a UDF RetReas (Return Reason) for Sales AR > Return. The UDF is applied to the rows. I need to block the adding of drafts if the UDF is blank. My code on the stored procedure, SBO_SP_TransactionNotification is not working. The draft for Return is still being added even if the UDF is blank. Here is the code

IF (@object_type ='112' AND @transaction_type IN ('A','U'))  
    BEGIN
	DECLARE @RetReason nvarchar(30)
SELECT @LineNum = b.VisOrder+1, @ObjType = CAST(A.ObjType as varchar(32)), @RetReason = COALESCE(B.U_RetReas,'') FROM ODRF A INNER JOIN DRF1 B ON A.DocEntry = B.DocEntry WHERE A.DocEntry = @list_of_cols_val_tab_del and ISNULL(A.WddStatus,'-') <> '-' IF (@ObjType = '16') IF ( @RetReason = '') BEGIN SET @error = -100018 SET @error_message=N'Return reason is required!' END END