USP_DELETE_RESEARCHGROUP

Executes the "Research Group: Delete" record operation.

Parameters

Parameter Parameter Type Mode Description
@ID uniqueidentifier IN Input parameter indicating the ID of the record being deleted.
@CHANGEAGENTID uniqueidentifier IN Input parameter indicating the ID of the change agent invoking the delete.
@CURRENTAPPUSERID uniqueidentifier IN Input parameter indicating the ID of the current user.

Definition

Copy


                    CREATE procedure dbo.USP_DELETE_RESEARCHGROUP (
                        @ID uniqueidentifier,
                        @CHANGEAGENTID uniqueidentifier,
                        @CURRENTAPPUSERID uniqueidentifier
                    ) as
                        set nocount on;

                        --check for prospect research requests

                        if exists(select 1 from dbo.PROSPECTRESEARCHREQUEST where RESEARCHGROUPID=@ID) begin
                            update dbo.PROSPECTRESEARCHREQUEST set RESEARCHGROUPID = null where RESEARCHGROUPID=@ID
                        end

                        --check for WealthPoint history

                        if exists(select 1 from dbo.WPSEARCHHISTORY where RESEARCHGROUPID=@ID and STATUSCODE in (0, 1, 2)) begin
                            raiserror('ERR_RESEARCHGROUP_CANNOTDELETE', 13, 1);
                            return 0;
                        end

                        if dbo.UFN_RESEARCHGROUP_USERCANMODIFY(@ID, @CURRENTAPPUSERID) = 1 begin
                            exec dbo.USP_RESEARCHGROUP_DELETEBYID_WITHCHANGEAGENTID @ID, @CHANGEAGENTID;
                            exec dbo.USP_USERSETTINGSLISTBUILDER_DELETEBYCONTEXTRECORD @ID, 'Research Group';
                        end
                        else begin
                            raiserror ('ERR_RESEARCHGROUP_CANNOTMODIFY',13,1);
                            return 0;
                        end

                        return 0;