USP_DATAFORM_EDIT_STEWARDSHIPPLANDETAILS_2
The save procedure used by the edit dataform template "Stewardship Plan Details Edit Form".
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@ID | uniqueidentifier | IN | The input ID parameter indicating the ID of the record being edited. |
@CURRENTAPPUSERID | uniqueidentifier | IN | Input parameter indicating the ID of the current user. |
@CHANGEAGENTID | uniqueidentifier | IN | Input parameter indicating the ID of the change agent invoking the procedure. |
@NAME | nvarchar(100) | IN | Plan name |
@MANAGERID | uniqueidentifier | IN | Manager |
@SITES | xml | IN | Sites |
@PLANTYPEID | uniqueidentifier | IN | Plan type |
@PLANSUBTYPEID | uniqueidentifier | IN | Plan subtype |
@STARTDATE | datetime | IN | Start date |
Definition
Copy
CREATE procedure dbo.USP_DATAFORM_EDIT_STEWARDSHIPPLANDETAILS_2
(
@ID uniqueidentifier,
@CURRENTAPPUSERID uniqueidentifier,
@CHANGEAGENTID uniqueidentifier = null,
@NAME nvarchar(100),
@MANAGERID uniqueidentifier,
@SITES xml,
@PLANTYPEID uniqueidentifier,
@PLANSUBTYPEID uniqueidentifier,
@STARTDATE datetime
)
as
set nocount on;
if @SITES is null
begin
if dbo.UFN_SITEREQUIREDFORUSER(@CURRENTAPPUSERID) = 1
begin
raiserror('BBERR_STEWARDSHIPPLANSITE_SITEID', 13, 1);
return 1;
end
end
declare @CHANGEDATE datetime = getdate();
if @CHANGEAGENTID is null
exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output;
begin try
update dbo.STEWARDSHIPPLAN set
NAME = @NAME,
MANAGERID = @MANAGERID,
STARTDATE = @STARTDATE,
CHANGEDBYID = @CHANGEAGENTID,
DATECHANGED = @CHANGEDATE,
PLANTYPECODEID = @PLANTYPEID,
PLANSUBTYPECODEID = @PLANSUBTYPEID
where
ID = @ID;
-- Add plan manager as a plan steward, if it doesn't already exist
--if not @MANAGERID is null
-- exec dbo.USP_STEWARDSHIPPLANSTEWARD_ADD @ID, @MANAGERID, @CHANGEAGENTID, @CHANGEDATE;
if not @SITES is null
exec dbo.USP_STEWARDSHIPPLAN_GETSITES_UPDATEFROMXML @ID, @SITES, @CHANGEAGENTID, @CHANGEDATE;
end try
begin catch
exec dbo.USP_RAISE_ERROR;
return 1;
end catch
return 0;