USP_DATAFORMTEMPLATE_ADD_BATCHWORKFLOWSTATE
The save procedure used by the add dataform template "Batch Workflow State Add Form".
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@ID | uniqueidentifier | INOUT | The output parameter indicating the ID of the record added. |
@NAME | nvarchar(200) | IN | Name |
@BATCHWORKFLOWID | uniqueidentifier | IN | Input parameter indicating the context ID for the record being added. |
@ALLOWCOMMIT | bit | IN | Allow batch to be committed when in this state |
@ISINITIALSTATE | bit | IN | This is the initial state for the workflow |
@ALLOWEDIT | bit | IN | Allow batch to be edited in this state |
@PERMISSIONS | xml | IN | |
@CHANGEAGENTID | uniqueidentifier | IN | Input parameter indicating the ID of the change agent invoking the procedure. |
@OVERDUEIN | tinyint | IN | Days allowed before batch is overdue |
@ENFORCETOTALMATCHING | bit | IN | Allow commit only when projected totals match batch totals |
Definition
Copy
CREATE procedure dbo.USP_DATAFORMTEMPLATE_ADD_BATCHWORKFLOWSTATE
(
@ID uniqueidentifier = null output,
@NAME nvarchar(200),
@BATCHWORKFLOWID uniqueidentifier,
@ALLOWCOMMIT bit = 0,
@ISINITIALSTATE bit = 0,
@ALLOWEDIT bit = 1,
@PERMISSIONS xml = null,
@CHANGEAGENTID uniqueidentifier = null,
@OVERDUEIN tinyint = 0,
@ENFORCETOTALMATCHING bit = 0
)
as
set nocount on;
if @CHANGEAGENTID is null
exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output
if @ID is null
set @ID = newid()
begin try
if @ISINITIALSTATE = 1
begin
if exists(select ID from dbo.BATCHWORKFLOWSTATE where ID <> @ID and BATCHWORKFLOWID = @BATCHWORKFLOWID and ISINITIALSTATE = 1)
update dbo.BATCHWORKFLOWSTATE set ISINITIALSTATE = 0 where BATCHWORKFLOWID = @BATCHWORKFLOWID
end
insert into dbo.BATCHWORKFLOWSTATE (ID, NAME, BATCHWORKFLOWID, ALLOWCOMMIT, ENFORCETOTALMATCHING, ISINITIALSTATE, ALLOWEDIT, OVERDUEIN, ADDEDBYID, CHANGEDBYID, DATEADDED, DATECHANGED)
values (@ID, @NAME, @BATCHWORKFLOWID, @ALLOWCOMMIT, @ENFORCETOTALMATCHING, @ISINITIALSTATE, @ALLOWEDIT, @OVERDUEIN, @CHANGEAGENTID, @CHANGEAGENTID, getdate(), getdate())
if not @PERMISSIONS is null
exec dbo.USP_BATCHWORKFLOWSTATE_GETSYSTEMROLEPERMISSIONS_ADDFROMXML @ID, @PERMISSIONS, @CHANGEAGENTID;
end try
begin catch
exec dbo.USP_RAISE_ERROR
return 1
end catch
return 0