cancel
Showing results for 
Search instead for 
Did you mean: 

Stored procedure to block delete specific type of Draft Document

Former Member
0 Kudos

Hi Dear,

How can I add control on stored procedure to block delete specific type of Draft Document, for example AR Invoice draft.

Following code not working, is there anyway to block it?


IF @object_type = '112'

BEGIN

    IF @TRANSACTION_TYPE = 'D'

    BEGIN   

        SELECT @error = -1, @error_message = 'Remove AR Invoice draft is not allowed'

        FROM ODRF T0

        WHERE T0.ObjType='13' AND T0.DocEntry = @list_of_cols_val_tab_del

    END   

END   

Please Help

Thanks in advance

Daisuki

Accepted Solutions (1)

Accepted Solutions (1)

kothandaraman_nagarajan
Active Contributor
0 Kudos

Hi,

Try:

IF @object_type = '112' 

BEGIN 

    IF @TRANSACTION_TYPE = 'U' 

BEGIN     

SELECT @error = -1, @error_message = 'Remove AR Invoice draft is not allowed' 

FROM ODRF T0 

WHERE T0.ObjType='13' AND T0.DocEntry = @list_of_cols_val_tab_del 

END     

END     

Thanks & Regards,

Nagarajan

Former Member
0 Kudos

Hi Nagarajan


Thank you for your prompt reply,

suggestion you given still not effective

kothandaraman_nagarajan
Active Contributor
0 Kudos

Alternatively you can set "No Authorization" to remove Document Draft under Sales-->Document Drafts Report.

Former Member
0 Kudos

Thank you Nagarajan,

but I intended to block for selected type of draft to reserve the running number, therefore, I cant use authority management function for all kind of drafts,

Anyway I'd found a way to solve it,

I created a [ADRF] table to store DraftKey(int) and ObjType(nvarchar) whenever draft is added.


IF @object_type = '112' 

BEGIN 

    IF @TRANSACTION_TYPE = 'D' 

     BEGIN     

          SELECT @error = -1, @error_message = 'Remove AR Invoice draft is not allowed' 

          FROM ADRF T0  -- Check ADRF instead of ODRF

          WHERE T0.ObjType='13' AND T0.DraftKey= @list_of_cols_val_tab_del 

     END     

END     

Thank you once again

kothandaraman_nagarajan
Active Contributor
0 Kudos

Thanks for feedback and sharing TN with us.

Answers (0)