USP_DATAFORMTEMPLATE_ADD_COMMITMULTIPLEBATCHES2PROCESS

The save procedure used by the add dataform template "Commit Multiple Batches Process Add Form 2".

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(200) IN Name
@DESCRIPTION nvarchar(1000) IN Description
@COMMIT tinyint IN Commit
@SELECTIONID uniqueidentifier IN Selection
@CREATEOUTPUTSELECTION bit IN Create output selections
@CREATEEXCEPTIONBATCHES bit IN Create exception batches
@PURGEBATCHES bit IN Delete batches after commit
@CREATEBATCHCONTROLREPORTS bit IN Create control reports
@CURRENTAPPUSERID uniqueidentifier IN Input parameter indicating the ID of the current user.
@SITEID uniqueidentifier IN Site

Definition

Copy

CREATE procedure dbo.USP_DATAFORMTEMPLATE_ADD_COMMITMULTIPLEBATCHES2PROCESS
(
    @ID uniqueidentifier OUTPUT,
    @CHANGEAGENTID uniqueidentifier,
    @NAME nvarchar(200),
    @DESCRIPTION nvarchar(1000) = '',
    @COMMIT tinyint = 0,
    @SELECTIONID uniqueidentifier = null,
    @CREATEOUTPUTSELECTION bit = 0,
    @CREATEEXCEPTIONBATCHES bit = 0,
    @PURGEBATCHES bit = 0,
    @CREATEBATCHCONTROLREPORTS bit = 0,
    @CURRENTAPPUSERID uniqueidentifier = null,
    @SITEID uniqueidentifier = null
)
as

begin
        set nocount on;

if @ID is null
    set @ID = newid()

if @CHANGEAGENTID is null  
    exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output;


begin try
            if (@SITEID is not null
            begin
                if dbo.UFN_SITEALLOWEDFORUSER(@CURRENTAPPUSERID, @SITEID) = 0 begin
                    raiserror ('ERR_SITE_NOACCESS',13,1);
                    return 1;
                end
            end

            insert into dbo.BATCHESCOMMITPROCESS (ID, NAME, DESCRIPTION, SELECTIONID, CREATEOUTPUTSELECTION, CREATEEXCEPTIONBATCHES, PURGEBATCHES, CREATEBATCHCONTROLREPORTS, ADDEDBYID, CHANGEDBYID, DATEADDED, DATECHANGED)
                values (@ID, @NAME, @DESCRIPTION, @SELECTIONID, @CREATEOUTPUTSELECTION, @CREATEEXCEPTIONBATCHES, @PURGEBATCHES, @CREATEBATCHCONTROLREPORTS, @CHANGEAGENTID, @CHANGEAGENTID, GetDate(), GetDate());

            exec dbo.USP_BUSINESSPROCESSINSTANCE_ADD @CHANGEAGENTID = @CHANGEAGENTID
                            @BUSINESSPROCESSCATALOGID = '8bda5883-5fc0-4b1e-b88a-b6cba975f515'
                            @BUSINESSPROCESSPARAMETERSETID = @ID
                            @OWNERID = @CURRENTAPPUSERID, @SITEID = @SITEID;
        end try

        begin catch
            exec dbo.USP_RAISE_ERROR;
            return 1;
        end catch

        return 0;

        end