USP_DATAFORMTEMPLATE_ADD_APPUSERSYSTEMROLEACCOUNTINGELEMENTSECURITY
The save procedure used by the add dataform template "Application User System Role Accounting Element Security Add Form".
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@ID | uniqueidentifier | INOUT | The output parameter indicating the ID of the record added. |
@SYSTEMROLEAPPUSERID | uniqueidentifier | IN | Input parameter indicating the context ID for the record being added. |
@CHANGEAGENTID | uniqueidentifier | IN | Input parameter indicating the ID of the change agent invoking the procedure. |
@ACCOUNTINGELEMENTSECURITYMODE | tinyint | IN | Record access |
@ACCOUNTINGELEMENTSECURITYGROUPS | xml | IN | Accounting element security groups |
Definition
Copy
CREATE procedure dbo.USP_DATAFORMTEMPLATE_ADD_APPUSERSYSTEMROLEACCOUNTINGELEMENTSECURITY
(
@ID uniqueidentifier = null output,
@SYSTEMROLEAPPUSERID uniqueidentifier,
@CHANGEAGENTID uniqueidentifier = null,
@ACCOUNTINGELEMENTSECURITYMODE tinyint = 0,
@ACCOUNTINGELEMENTSECURITYGROUPS xml = null
)
as
set nocount on;
if @ID is null
set @ID = newid()
if @CHANGEAGENTID is null
exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output
declare @CURRENTDATE datetime
set @CURRENTDATE = getdate()
begin try
if @ACCOUNTINGELEMENTSECURITYMODE <> 0 and @ACCOUNTINGELEMENTSECURITYGROUPS is null
raiserror('ERR_ACCOUNTINGELEMENTSECURITY_ATLEASTONE',13,1);
else if @ACCOUNTINGELEMENTSECURITYMODE = 0
set @ACCOUNTINGELEMENTSECURITYGROUPS = null
declare @ERRORMESSAGE nvarchar(max);
declare @DULICATEID uniqueidentifier
select top 1 @DULICATEID = ACCOUNTINGELEMENTSECURITYGROUPID from dbo.UFN_SYSTEMROLEAPPUSER_GETACCOUNTINGELEMENTSECURITYGROUPS_FROMITEMLISTXML(@ACCOUNTINGELEMENTSECURITYGROUPS) as GROUPS group by ACCOUNTINGELEMENTSECURITYGROUPID having count(ACCOUNTINGELEMENTSECURITYGROUPID) > 1
if @DULICATEID is not null
begin
select @ERRORMESSAGE = NAME + ' is selected more than once.' from dbo.ACCOUNTINGELEMENTSECURITYGROUP where ID = @DULICATEID;
raiserror(@ERRORMESSAGE, 13, 1);
end
update dbo.SYSTEMROLEAPPUSER
set ACCOUNTINGELEMENTSECURITYMODECODE = @ACCOUNTINGELEMENTSECURITYMODE
where ID = @SYSTEMROLEAPPUSERID
exec dbo.USP_SYSTEMROLEAPPUSER_GETACCOUNTINGELEMENTSECURITYGROUPS_ADDFROMXML @SYSTEMROLEAPPUSERID, @ACCOUNTINGELEMENTSECURITYGROUPS, @CHANGEAGENTID, @CURRENTDATE;
set @ID = @SYSTEMROLEAPPUSERID
end try
begin catch
exec dbo.USP_RAISE_ERROR
return 1
end catch
return 0