USP_DATAFORMTEMPLATE_EDIT_PROSPECTRESEARCHREQUESTASSIGN
The save procedure used by the edit dataform template "Prospect Research Request Assign Edit Form".
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@ID | uniqueidentifier | IN | The input ID parameter indicating the ID of the record being edited. |
@CHANGEAGENTID | uniqueidentifier | IN | Input parameter indicating the ID of the change agent invoking the procedure. |
@ASSIGNEDTOID | uniqueidentifier | IN | Researcher |
@ASSIGNCHILDREN | bit | IN | Assign individual requests to the same researcher |
@CURRENTAPPUSERID | uniqueidentifier | IN | Input parameter indicating the ID of the current user. |
Definition
Copy
CREATE procedure dbo.USP_DATAFORMTEMPLATE_EDIT_PROSPECTRESEARCHREQUESTASSIGN (
@ID uniqueidentifier,
@CHANGEAGENTID uniqueidentifier = null,
@ASSIGNEDTOID uniqueidentifier,
@ASSIGNCHILDREN bit,
@CURRENTAPPUSERID uniqueidentifier
)
as
set nocount on;
if @CHANGEAGENTID is null
exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output
declare @CURRENTDATE datetime
set @CURRENTDATE = getdate()
begin try
-- handle updating the data
declare @STATUSCODE tinyint
select @STATUSCODE = STATUSCODE from dbo.PROSPECTRESEARCHREQUEST where ID = @ID
declare @ASSIGNEDTOAPPUSERID uniqueidentifier = null;
select @ASSIGNEDTOAPPUSERID = APPUSER.ID from dbo.APPUSER where APPUSER.CONSTITUENTID = @ASSIGNEDTOID;
if not dbo.UFN_PROSPECTRESEARCHREQUEST_USERHASSITEACCESS(@ID, @ASSIGNEDTOAPPUSERID, 'abcec68e-14fa-42c3-a45f-2d401a681ae1', 1) = 1
raiserror('BBERR_ASSIGNEDTO_SITE_ACCESSDENIED', 13, 1);
if @STATUSCODE in (1, 2, 3) begin
update dbo.PROSPECTRESEARCHREQUEST set
STATUSCODE = 2,
ASSIGNEDTOID = @ASSIGNEDTOID,
CHANGEDBYID = @CHANGEAGENTID,
DATECHANGED = @CURRENTDATE
where ID = @ID
if @ASSIGNCHILDREN = 1 begin
update dbo.PROSPECTRESEARCHREQUESTCONSTITUENT set
STATUSCODE = 2,
ASSIGNEDTOID = @ASSIGNEDTOID,
CHANGEDBYID = @CHANGEAGENTID,
DATECHANGED = @CURRENTDATE
where
PROSPECTRESEARCHREQUESTID = @ID and STATUSCODE in (1, 2)
end
exec dbo.USP_PROSPECTRESEARCHREQUEST_ASSIGNEDALERT_SEND @CURRENTAPPUSERID, @ID
end
else begin
raiserror('BBERR_PROSPECTRESEARCHREQUEST_BADASSIGNSTATE', 13, 1);
return 1;
end
end try
begin catch
exec dbo.USP_RAISE_ERROR
return 1
end catch
return 0;