USP_DATAFORMTEMPLATE_ADD_APPEAL
The save procedure used by the add dataform template "Appeal Add Form".
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@ID | uniqueidentifier | INOUT | The output parameter indicating the ID of the record added. |
@CHANGEAGENTID | uniqueidentifier | IN | Input parameter indicating the ID of the change agent invoking the procedure. |
@NAME | nvarchar(100) | IN | Name |
@DESCRIPTION | nvarchar(255) | IN | Description |
@APPEALCATEGORYCODEID | uniqueidentifier | IN | Category |
@BUSINESSUNITCODEID | uniqueidentifier | IN | Business unit |
@STARTDATE | datetime | IN | Start date |
@ENDDATE | datetime | IN | End date |
@GOAL | money | IN | Goal |
@APPEALREPORT1CODEID | uniqueidentifier | IN | Report code |
@SITEID | uniqueidentifier | IN | Site |
@MEMBERSHIPPROGRAMID | uniqueidentifier | IN | Membership |
@CURRENTAPPUSERID | uniqueidentifier | IN | Input parameter indicating the ID of the current user. |
@BUSINESSUNITS | xml | IN | Business units |
Definition
Copy
CREATE procedure dbo.USP_DATAFORMTEMPLATE_ADD_APPEAL
(
@ID uniqueidentifier = null output,
@CHANGEAGENTID uniqueidentifier = null,
@NAME nvarchar(100) = '',
@DESCRIPTION nvarchar(255) = '',
@APPEALCATEGORYCODEID uniqueidentifier = null,
@BUSINESSUNITCODEID uniqueidentifier= null,
@STARTDATE datetime = null,
@ENDDATE datetime = null,
@GOAL money = 0,
@APPEALREPORT1CODEID uniqueidentifier = null,
@SITEID uniqueidentifier = null,
@MEMBERSHIPPROGRAMID uniqueidentifier = null,
@CURRENTAPPUSERID uniqueidentifier,
@BUSINESSUNITS xml = null
)
as
begin
set nocount on;
IF @ID is null
set @ID = newid()
if @CHANGEAGENTID is null
exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output
if @SITEID is null
begin
if dbo.UFN_SITEREQUIREDFORUSER(@CURRENTAPPUSERID) = 1
begin
raiserror('Site is required.',13,1)
return
end
end
begin try
declare @CURRENTDATE datetime;
set @CURRENTDATE = getdate();
declare @BASECURRENCYID uniqueidentifier = dbo.UFN_APPUSER_GETBASECURRENCY(@CURRENTAPPUSERID);
declare @ORGANIZATIONGOAL money;
declare @ORGANIZATIONEXCHANGERATEID uniqueidentifier;
exec dbo.USP_CURRENCY_GETCURRENCYVALUES
@GOAL,
@CURRENTDATE,
@BASECURRENCYID,
null,
null,
null,
null,
@ORGANIZATIONGOAL output,
@ORGANIZATIONEXCHANGERATEID output,
1;
insert into dbo.APPEAL (
ID,
NAME,
DESCRIPTION,
APPEALCATEGORYCODEID,
BUSINESSUNITCODEID,
STARTDATE,
ENDDATE,
GOAL,
APPEALREPORT1CODEID,
ISACTIVE,
SITEID,
MEMBERSHIPPROGRAMID,
ADDEDBYID,
CHANGEDBYID,
DATEADDED,
DATECHANGED,
BASECURRENCYID,
ORGANIZATIONGOAL,
ORGANIZATIONEXCHANGERATEID
) VALUES (
@ID,
@NAME,
@DESCRIPTION,
@APPEALCATEGORYCODEID,
null,
@STARTDATE,
@ENDDATE,
@GOAL,
@APPEALREPORT1CODEID,
1,
@SITEID,
@MEMBERSHIPPROGRAMID,
@CHANGEAGENTID,
@CHANGEAGENTID,
@CURRENTDATE,
@CURRENTDATE,
@BASECURRENCYID,
@ORGANIZATIONGOAL,
@ORGANIZATIONEXCHANGERATEID
)
if @BUSINESSUNITCODEID is null
exec dbo.USP_APPEALBUSINESSUNIT_GETBUSINESSUNITS_ADDFROMXML @ID, @BUSINESSUNITS, @CHANGEAGENTID;
else
insert into dbo.APPEALBUSINESSUNIT
(ID,APPEALID,BUSINESSUNITCODEID,ADDEDBYID,CHANGEDBYID)
values
(newid(),@ID,@BUSINESSUNITCODEID,@CHANGEAGENTID,@CHANGEAGENTID);
end try
begin catch
exec dbo.USP_RAISE_ERROR
return 1
end catch
return 0
end