USP_DATAFORMTEMPLATE_ADD_DOCUMENTREPRINT

The save procedure used by the add dataform template "DocumentReprint Add Data Form".

Parameters

Parameter Parameter Type Mode Description
@ID uniqueidentifier INOUT The output parameter indicating the ID of the record added.
@DOCUMENTPRINTINGHISTORYID 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.
@WORKSTATIONID uniqueidentifier IN
@WORKSTATIONMACHINENAME nvarchar(255) IN

Definition

Copy

CREATE procedure dbo.USP_DATAFORMTEMPLATE_ADD_DOCUMENTREPRINT
(
    @ID uniqueidentifier = null output,
    @DOCUMENTPRINTINGHISTORYID uniqueidentifier,
    @CHANGEAGENTID uniqueidentifier = null,    
    @WORKSTATIONID uniqueidentifier = null,
    @WORKSTATIONMACHINENAME nvarchar(255) = 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()

declare @CURRENTDATETIMEOFFSET datetimeoffset
set @CURRENTDATETIMEOFFSET = dbo.UFN_TIMEZONEENTRY_GETSYSTEMDEFAULTDATEWITHTIMEOFFSET(getutcdate(), 1)

begin try
    if @WORKSTATIONID is null and (@WORKSTATIONMACHINENAME is not null or @WORKSTATIONMACHINENAME <> '')
    begin
        set @WORKSTATIONID = dbo.UFN_WORKSTATION_GETIDBYMACHINENAME(@WORKSTATIONMACHINENAME);
    end

    update dbo.DOCUMENTPRINTINGHISTORY
    set WORKSTATIONID = @WORKSTATIONID,
        PRINTDATEWITHTIMEOFFSET = @CURRENTDATETIMEOFFSET,
        CHANGEDBYID = @CHANGEAGENTID,
        DATECHANGED = @CURRENTDATE
    where
        ID = @DOCUMENTPRINTINGHISTORYID

end try

begin catch
    exec dbo.USP_RAISE_ERROR
    return 1
end catch

return 0