USP_DATALIST_PROSPECT_PROSPECTPLANSHISTORICAL

List of historical prospect plans.

Parameters

Parameter Parameter Type Mode Description
@CURRENTAPPUSERID uniqueidentifier IN Input parameter indicating the ID of the current user.
@PROSPECTID uniqueidentifier IN Input parameter indicating the context ID for the data list.
@SECURITYFEATUREID uniqueidentifier IN Input parameter indicating the ID of the feature to use for site security checking.
@SECURITYFEATURETYPE tinyint IN Input parameter indicating the type of the feature to use for site security checking.

Definition

Copy


                CREATE procedure dbo.USP_DATALIST_PROSPECT_PROSPECTPLANSHISTORICAL
                (
                    @CURRENTAPPUSERID uniqueidentifier,
                    @PROSPECTID uniqueidentifier,
                    @SECURITYFEATUREID uniqueidentifier = null,
                    @SECURITYFEATURETYPE tinyint = null
                ) as begin
                    set nocount on;

                    select
                        PP.ID,
                        NI.ID,
                        dbo.UFN_PROSPECTPLANTYPECODE_GETDESCRIPTION(PP.PROSPECTPLANTYPECODEID) PLANOUTLINE
                    from
                        dbo.PROSPECTPLAN PP
                        left outer join dbo.INTERACTION NI on NI.ID = dbo.UFN_PROSPECTPLAN_GETNEXTSTEP(PP.ID)
                    where
                        PP.PROSPECTID=@PROSPECTID and
                        PP.ISACTIVE=0 
                        and (
                            select count(*
                            from dbo.UFN_SITEID_MAPFROM_PROSPECTPLANID(PP.ID) as PROSPECTPLANSITE 
                            where (dbo.UFN_APPUSER_ISSYSADMIN(@CURRENTAPPUSERID) = 1 or exists (select 1 from dbo.UFN_SITESFORUSERONFEATURE(@CURRENTAPPUSERID,@SECURITYFEATUREID,@SECURITYFEATURETYPE) where SITEID=[PROSPECTPLANSITE].[SITEID] or (SITEID is null and [PROSPECTPLANSITE].[SITEID] is null)))
                        ) > 0
                    order by
                        PLANOUTLINE
                end