UFN_SITEID_MAPFROM_INTERACTIONATTACHMENTID
Maps an INTERACTIONATTACHMENTID to a SITEID
Return
Return Type |
---|
table |
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@INTERACTIONATTACHMENTID | uniqueidentifier | IN |
Definition
Copy
CREATE function dbo.UFN_SITEID_MAPFROM_INTERACTIONATTACHMENTID(@INTERACTIONATTACHMENTID uniqueidentifier)
returns table
as
return
select coalesce(PROSPECTPLANSITE.SITEID,FUNDINGPLAN.SITEID,INTERACTIONSITE.SITEID) SITEID
from dbo.INTERACTIONATTACHMENT
inner join dbo.INTERACTION on INTERACTION.ID = INTERACTIONATTACHMENT.INTERACTIONID
left outer join dbo.PROSPECTPLANSITE on INTERACTION.PROSPECTPLANID = PROSPECTPLANSITE.PROSPECTPLANID
left outer join dbo.INTERACTIONSITE on INTERACTIONSITE.INTERACTIONID = INTERACTION.ID and dbo.UFN_INTERACTION_ISPLANSTEP(INTERACTION.ID) = 0
left outer join dbo.FUNDINGREQUEST on FUNDINGREQUEST.ID = INTERACTION.FUNDINGREQUESTID
left outer join dbo.FUNDINGPLAN on FUNDINGPLAN.ID = FUNDINGREQUEST.FUNDINGPLANID
where INTERACTIONATTACHMENT.ID = @INTERACTIONATTACHMENTID;