Show/Hide Toolbars

Use HistoryService when working with history records.

Whenever a Service operation requires HistoryService, set up HistoryService using the following code:

HistoryService historyService = platform.getHistoryService();

Creating a History Entry

The following sample creates a history entry. During history creation, you can use API interface methods to set objects in the entry, such as the history description and the category.

// Creates an empty history object.        

History newHistory = historyService.newHistory("history", parentEntity);

Reading a History Entry

The following sample returns a history entry using its primary key.

// Reads the Entity object based on the primary key provided

historyService.read(primaryKey);

Finding a History Entry

The following samples return all history entries for a particular entity and the most recent entry for an entity.

List<History> histories = historyService.getHistories(entity);

// Return most recent history with specified category and for a particular entity

History lastHistory = historyService.getLastHistory(entity, "HIST_STAT");

Deleting a History Entry

The following samples delete a history entity.

// Deletes the Entity object

historyService.delete(history);

// Deletes the Entity object based on the primary key provided

historyService.delete(primaryKey);