USP_DATAFORMTEMPLATE_EDIT_ADDPROSPECTPLANSPREPROCESS
The save procedure used by the edit dataform template "Add Prospect Plans Preprocess 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. |
@PROSPECTPLANNAME | nvarchar(100) | IN | Plan name |
@NARRATIVE | nvarchar(1000) | IN | Narrative |
@STARTDATETYPECODE | tinyint | IN | Plan start date |
@STARTDATE | date | IN | Plan start date |
@DAYSBEFOREORAFTER | int | IN | Days before/after this process runs |
Definition
Copy
CREATE procedure dbo.USP_DATAFORMTEMPLATE_EDIT_ADDPROSPECTPLANSPREPROCESS (
@ID uniqueidentifier,
@CHANGEAGENTID uniqueidentifier = null,
@PROSPECTPLANNAME nvarchar(100),
@NARRATIVE nvarchar(1000),
@STARTDATETYPECODE tinyint,
@STARTDATE date,
@DAYSBEFOREORAFTER int
)
as
set nocount on;
if @CHANGEAGENTID is null
exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output
declare @CURRENTDATE datetime
set @CURRENTDATE = getdate()
begin try
update dbo.ADDPROSPECTPLANSPROCESS set
PROSPECTPLANNAME = @PROSPECTPLANNAME,
NARRATIVE = @NARRATIVE,
STARTDATETYPECODE = @STARTDATETYPECODE,
STARTDATE = case @STARTDATETYPECODE when 1 then @STARTDATE end,
DAYSBEFOREORAFTER = case when @STARTDATETYPECODE in (2,3) then @DAYSBEFOREORAFTER else 0 end,
CHANGEDBYID = @CHANGEAGENTID,
DATECHANGED = @CURRENTDATE
where ID = @ID;
end try
begin catch
exec dbo.USP_RAISE_ERROR
return 1
end catch
return 0;