USP_RECORDOPERATION_WEALTHCAPACITYFORMULARECALCULATECONSTITUENT

Executes the "Wealth Capacity Formula: Recalculate Constituent" record operation.

Parameters

Parameter Parameter Type Mode Description
@ID nchar 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_WEALTHCAPACITYFORMULARECALCULATECONSTITUENT (
                        @ID nchar(72),
                        @CHANGEAGENTID uniqueidentifier
                    ) as
                        set nocount on;

                        declare @APPLYTOID uniqueidentifier;
                        declare @WEALTHCAPACITYFORMULAID uniqueidentifier;
                        declare @CONSTITUENTID uniqueidentifier;
                        declare @VALIDIDS bit;

                        begin try
                            set @WEALTHCAPACITYFORMULAID = convert(uniqueidentifier,substring(@ID,0,37));
                            set @CONSTITUENTID = convert(uniqueidentifier,substring(@ID,37,37));
                            set @VALIDIDS = 1;
                        end try
                        begin catch
                            set @VALIDIDS = 0;
                        end catch

                        if @VALIDIDS = 1 begin
                            select
                                @APPLYTOID = WC.ID
                            from
                                dbo.WEALTHCAPACITY WC
                            where
                                WC.WEALTHCAPACITYFORMULAID = @WEALTHCAPACITYFORMULAID and
                                WC.CONFIRMED = 0 and
                                WC.ID = @CONSTITUENTID;

                            exec dbo.USP_WEALTHCAPACITY_UPDATE @APPLYTOID, @CHANGEAGENTID;
                        end

                        return 0;