USP_DESIGNATIONGOAL_DELETE
Executes the "Designation Goal: 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. | 
Definition
 Copy 
                                    
                    CREATE procedure dbo.USP_DESIGNATIONGOAL_DELETE(@ID uniqueidentifier, @CHANGEAGENTID uniqueidentifier)
                    as begin
                        --check deletion rules, if any
                        declare @KPIS integer;
                        WITH XMLNAMESPACES (
                          'bb_appfx_dataforms' AS DFI)
                        select @KPIS = count(*)
                            from dbo.KPIINSTANCE
                                where KPIINSTANCE.CONTEXTRECORDID = (select cast(DESIGNATIONID as nvarchar(36)) 
                                                                        from dbo.DESIGNATIONGOAL
                                                                        where ID = @ID)
                                    and kpiinstance.parametersxml.value('data(/DFI:DataFormItem/DFI:Values/DFI:fv[@ID="DESIGNATIONGOALID"]/DFI:Value)[1]','varchar(36)') = cast(@ID as varchar(36))
                        if @KPIS > 0 
                            begin
                                raiserror('This goal has an associated KPI and cannot be deleted.', 13, 1);
                                return 0;
                            end
                        exec USP_DESIGNATIONGOAL_DELETEBYID_WITHCHANGEAGENTID @ID, @CHANGEAGENTID
                        return 0;
                    end