USP_PROSPECTRESEARCHREQUESTCONSTITUENT_ACCEPT
Executes the "Prospect Research Request Constituent: Accept" record operation.
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@ID | uniqueidentifier | IN | Input parameter indicating the ID of the record being updated. |
@CHANGEAGENTID | uniqueidentifier | IN | Input parameter indicating the ID of the change agent invoking the update. |
@CURRENTAPPUSERID | uniqueidentifier | IN | Input parameter indicating the ID of the current user. |
Definition
Copy
CREATE procedure dbo.USP_PROSPECTRESEARCHREQUESTCONSTITUENT_ACCEPT
(
@ID uniqueidentifier,
@CHANGEAGENTID uniqueidentifier,
@CURRENTAPPUSERID uniqueidentifier
)
as begin
if @CHANGEAGENTID is null
exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output
declare @CURRENTDATE datetime
set @CURRENTDATE = getdate()
declare @CONSTITUENTID uniqueidentifier
select @CONSTITUENTID = CONSTITUENTID from dbo.APPUSER where ID = @CURRENTAPPUSERID
if dbo.UFN_CONSTITUENT_ISFUNDRAISER(@CONSTITUENTID) = 1 begin
update
dbo.PROSPECTRESEARCHREQUESTCONSTITUENT
set
STATUSCODE = 3,
ASSIGNEDTOID = @CONSTITUENTID,
CHANGEDBYID = @CHANGEAGENTID,
DATECHANGED = @CURRENTDATE
where
ID = @ID and STATUSCODE in(1, 2, 3)
declare @PROSPECTRESEARCHREQUESTID uniqueidentifier
declare @PARENTASSIGNEDTOID uniqueidentifier
select
@PROSPECTRESEARCHREQUESTID = PRRC.PROSPECTRESEARCHREQUESTID,
@PARENTASSIGNEDTOID = PRR.ASSIGNEDTOID
from
dbo.PROSPECTRESEARCHREQUESTCONSTITUENT PRRC
left join
dbo.PROSPECTRESEARCHREQUEST PRR on PRR.ID = PRRC.PROSPECTRESEARCHREQUESTID
where
PRRC.ID = @ID
if coalesce(@PARENTASSIGNEDTOID, '00000000-0000-0000-0000-000000000000') = '00000000-0000-0000-0000-000000000000' begin
update dbo.PROSPECTRESEARCHREQUEST set
STATUSCODE = 3,
ASSIGNEDTOID = @CONSTITUENTID,
CHANGEDBYID = @CHANGEAGENTID,
DATECHANGED = @CURRENTDATE
where
ID = @PROSPECTRESEARCHREQUESTID
end
end
else begin
raiserror('To accept a prospect research request the current user must be linked to an individual constituent record and have a Fundraiser constituency.', 13, 1);
return 1;
end
return 0;
end