UFN_PROSPECTPLAN_GETNEXTSTEP
Returns the ID of the next step to complete for a given prospect.
Return
| Return Type |
|---|
| uniqueidentifier |
Parameters
| Parameter | Parameter Type | Mode | Description |
|---|---|---|---|
| @PROSPECTPLANID | uniqueidentifier | IN |
Definition
Copy
CREATE function dbo.UFN_PROSPECTPLAN_GETNEXTSTEP(@PROSPECTPLANID uniqueidentifier)
returns uniqueidentifier
as begin
return (
select top 1
INTERACTION.ID
from
dbo.INTERACTION (nolock)
where
INTERACTION.PROSPECTPLANID = @PROSPECTPLANID
and INTERACTION.COMPLETED = 0
and (INTERACTION.STATUSCODE = 0 or INTERACTION.STATUSCODE = 1)
order by
INTERACTION.STATUSCODE desc, --TommyVe 2009-10-26 Pull the first Planned step if no Pending steps exist
INTERACTION.EXPECTEDDATE,
INTERACTION.DATEADDED,
INTERACTION.ID
)
end