USP_DATAFORMTEMPLATE_EDIT_SYSTEMROLE_TASKS

The save procedure used by the edit dataform template "System Role Assign Tasks Edit Form".

Parameters

Parameter Parameter Type Mode Description
@ID uniqueidentifier IN The input ID parameter indicating the ID of the record being edited.
@CHANGEAGENTID uniqueidentifier IN Input parameter indicating the ID of the change agent invoking the procedure.
@TASKLIST xml IN Assigned Task List

Definition

Copy


CREATE procedure dbo.USP_DATAFORMTEMPLATE_EDIT_SYSTEMROLE_TASKS
(
    @ID uniqueidentifier,
    @CHANGEAGENTID uniqueidentifier = null,
    @TASKLIST xml
)    
as
set nocount on;

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

declare @CURRENTDATE datetime;
set @CURRENTDATE = getdate();

begin try

  exec dbo.USP_SYSTEMROLE_GETTASKLIST_UPDATEFROMXML @ID, @TASKLIST, @CHANGEAGENTID;

  --ChristineVi 8/15/2014 - WI 386588 - Set DATECHANGED after executing other code in case that code errors out.

  --If this update is done before the exec, a TSLONG error will occur if the first error is dismissed and the form is saved again.

  update dbo.SYSTEMROLE 
  set
    CHANGEDBYID = @CHANGEAGENTID,
    DATECHANGED = @CURRENTDATE
  where ID = @ID;

  return 0;

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