USP_RECORDOPERATION_LETTERCODEMARKINACTIVE

Executes the "Revenue Letter: Mark Inactive" record operation.

Parameters

Parameter Parameter Type Mode Description
@ID uniqueidentifier IN Input parameter indicating the ID of the record being updated.
@CHANGEAGENTID uniqueidentifier IN Input parameter indicating the ID of the change agent invoking the update.

Definition

Copy


                    CREATE procedure dbo.USP_RECORDOPERATION_LETTERCODEMARKINACTIVE
                    (
                        @ID uniqueidentifier,
                        @CHANGEAGENTID uniqueidentifier = null
                    )
                    as
                        set nocount on;

                        if (select count(LETTERCODES.ID) from dbo.ASSIGNLETTERCODESPROCESSLETTERCODES LETTERCODES where LETTERCODEID = @ID) > 0
                        begin
                            raiserror('This letter is being used by an assign letters process and cannot be marked inactive.',13,1);
                            return 0;
                        end

                        if (select count(ID) from dbo.ACKNOWLEDGEMENTPROCESS where LETTERCODEID = @ID) > 0
                        begin
                            raiserror('This letter is being used by an acknowledgement process and cannot be marked inactive.',13,1);
                            return 0;
                        end

                        if @CHANGEAGENTID is null  
                            exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output;

                        update
                            dbo.LETTERCODE
                        set
                            ISACTIVE = 0,
                            CHANGEDBYID = @CHANGEAGENTID,
                            DATECHANGED = getdate()
                        where
                            LETTERCODE.ID = @ID;

                        return 0;