UFN_PROSPECTPLAN_GETLASTSTEP

Returns the ID of the most recently completed step for a given prospect.

Return

Return Type
uniqueidentifier

Parameters

Parameter Parameter Type Mode Description
@PROSPECTPLANID uniqueidentifier IN

Definition

Copy


            CREATE function dbo.UFN_PROSPECTPLAN_GETLASTSTEP(@PROSPECTPLANID uniqueidentifier)
            returns uniqueidentifier
            as begin
                return (
                    select top 1 I.ID
                    from dbo.INTERACTION I
                    where I.PROSPECTPLANID=@PROSPECTPLANID and I.COMPLETED=1
                    order by I.ACTUALDATE desc, I.DATEADDED desc, I.ID
                )
            end