USP_DATAFORMTEMPLATE_VIEW_EVENTTEAMFUNDRAISERFROMCONSTITUENTANDAPPEAL
The load procedure used by the view dataform template "Event Team Fundraiser from Constituent and Appeal View Form"
Parameters
| Parameter | Parameter Type | Mode | Description | 
|---|---|---|---|
| @ID | nvarchar(72) | IN | The input ID parameter used to load the fields defined on the form. | 
| @DATALOADED | bit | INOUT | Output parameter indicating whether or not data was actually loaded. | 
| @GOAL | money | INOUT | Goal | 
| @ISREGISTRANT | bit | INOUT | Is registrant | 
| @BASECURRENCYID | uniqueidentifier | INOUT | Base currency | 
Definition
 Copy 
                                    
                CREATE procedure dbo.USP_DATAFORMTEMPLATE_VIEW_EVENTTEAMFUNDRAISERFROMCONSTITUENTANDAPPEAL
                (
                    @ID nvarchar(72),
                    @DATALOADED bit = 0 output,
                    @GOAL money = null output,
                    @ISREGISTRANT bit = null output,
                    @BASECURRENCYID uniqueidentifier = null output
                )
                as
                begin
                    set nocount on;
                    set @DATALOADED = 0;
                    select
                        @DATALOADED = 1,
                        @GOAL = TEAMFUNDRAISER.GOAL,
                        @BASECURRENCYID = TEAMFUNDRAISER.BASECURRENCYID
                    from
                        dbo.TEAMFUNDRAISER
                    where
                        TEAMFUNDRAISER.CONSTITUENTID = left(@ID, 36)
                        and TEAMFUNDRAISER.APPEALID = right(@ID, 36);
                    --For constituents that are not team fundraisers this view returns the default goal
                    if @DATALOADED = 0
                    begin
                        select
                            @DATALOADED = 1,
                            @GOAL = 0
                        from
                            dbo.CONSTITUENT
                        where
                            CONSTITUENT.ID = left(@ID, 36);
                        -- Get the base currency from the appeal if the constituent is not a team fundraiser.
                        select @BASECURRENCYID = BASECURRENCYID from dbo.APPEAL where ID = right(@ID, 36);
                    end
                    if @DATALOADED = 1
                        begin
                            if exists
                            (
                                select
                                    1
                                from
                                    dbo.REGISTRANT
                                    inner join dbo.EVENT on REGISTRANT.EVENTID = EVENT.ID
                                where
                                    EVENT.APPEALID = right(@ID,36)
                                    and REGISTRANT.CONSTITUENTID = left(@ID,36)
                            )
                                set @ISREGISTRANT = 1;
                            else
                                set @ISREGISTRANT = 0;
                        end
                    return 0;
                end