AddHistory is used to create a workflow request history entry. This is useful if you want to track any actions, comments or time stamps at each status in the workflow.
AddHistory is usually called in a workflow status process, button process, or stand alone process. Once the service is called, a record will be created in the EP_Workflow_Request_History table. AddHistory won’t override or delete any existing record in the table. Since the Workflow Request Id is a required input of the service, a workflow request must be created before you call AddHistory.
Having a history of the workflow request can be useful for developers to see that status progression. Also, since the developer determines the messages that are written to the database, you can make user friendly messages that inform site users of statuses. You can then build a page or web part for request history and display any information needed.
If you have any question about EASYProcess workflow, please refer to the Workflow document for further explanation.
AddHistory Use Examples
Basic AddHistory Use
In this example, we call AddHistory in the workflow CompleteStatus process. Since we use it in a workflow process, all required fields are pre-populated for you. The only thing you might want to change is the comment field. The default value comes from ExecuteWorkflow service, since it is inside a CompleteStatus process. If you use AddHistory in StatusArrival and StatusExit, you will need to specify the comment field.
In the log, it only shows the start time and end time of the service.
In EP_Workflow_Request_History table, you’ll see this history entry. CreatedBy, CreatedOn, UpdatedBy and UpdatedOn will be populated automatically with the UserId and current date time. You can then build a page or web part for request history and display any information you need.
If you call AddHistory in other process, you will need to enter all required fields to meet your audit design. Please note that all required fields cannot be blank, otherwise, you will not be able to the save the service. The following is a sample input calling from button process.
AddHistory with custom data
This is an example that we write a history record to the request in previous example with all custom data fields typed in.
In the EP_Workflow_Request_History table, you will see the history record is populated with all CustomData columns filled out.