Post Workspace Create event handlers

You can use Post Workspace Create event handlers to update database tables as part of the workspace creation process. You can also use them to make direct SQL calls and to perform other operations on a workspace or EDDS database. This event handler runs as the final task performed during workspace creation.

For example, you might want to use a workspace with a custom application as a template. If the application includes custom tables on the workspace database, you can use a Post Workspace Create event handler to clear obsolete data from these tables when you create your new workspace and its database. You could also use this type of event handler to update tables in the EDDS with entries for a newly installed application in a workspace.

Note: When a Post Workspace Create event handler fails to finish executing, the Workspace Details page displays an error message and the Re-run Post Workspace Create Event Handlers button in the Relativity Utilities console. Click this button to run the event handler again. If the Post Workspace Create event handlers continue to fail, contact Client Services.

This page contains the following information:

Guidelines for Post Workspace Create event handlers

Use these guidelines when developing Post Workspace Create event handlers:

Code sample for a Post Workspace Create event handler

Review the following code sample for a Post Workspace Create event handler.

using System;
using System.Data.SqlClient;

namespace Relativity.Samples.EventHandlers
      /// <summary>
      /// This event handler cleans up the workspace scratch table of records that were used in the template workspace
      /// </summary>
      [kCura.EventHandler.CustomAttributes.Description("Cleans application tables after workspace is used for a template")]
      class SamplePostWorkspaceCreate : kCura.EventHandler.PostWorkspaceCreateEventHandlerBase
            public override kCura.EventHandler.Response Execute()
                  //Construct a response object with default values
                  kCura.EventHandler.Response retVal = new kCura.EventHandler.Response();
                  retVal.Message = String.Empty;
                  retVal.Success = true;
                        //Get the current workspace artifact ID
                        Int32 currentWorkspaceID = this.Helper.GetActiveCaseID();
                        //Get the current workspace database context
                        Relativity.API.IDBContext workspaceDBContext = this.Helper.GetDBContext(currentWorkspaceID);
                        //Remove entries from the table that were for objects in the old case
                  catch (System.Exception ex)
                        //Catch an exception if it occurs, log it, and return a response with success = false.
                        retVal.Success = false;
                        retVal.Message = ex.ToString();

                  return retVal;

            /// <summary>
            /// Removes entries from application tables in the workspace
            /// </summary>
            /// <param name="workspaceDBContext">Context object to the current workspace</param>
            private static void TruncateLocalTable(Relativity.API.IDBContext workspaceDBContext)
                  String deleteWaitingJobsSQL = "TRUNCATE TABLE [SamplesAppScratchTable]";

Community Updates

Aero Developer FAQ Evolving the Platform Most recent release notes
Learn more Learn more Learn more

Additional Resources

Access Third-Party Tools with GitHub     Create .NET Apps Faster with NuGet
Visit github     visit nuget