A fact allows you to trace an action performed on a component and thus provide a component history.
Factual information
The facts are made up of several pieces of information that allow us to identify the precise action performed and its context.
Object identification
The object on which a fact took place can be identified from the object type and its identifier.
Functions | Description |
---|---|
getObjectType() | Object type retrieval |
setObjectType(type) | Modification object type |
getObjectId() | Object identifier retrieval |
setObjectId(id) | Object identifier modification |
Context
In order to provide information on the context in which a fact took place, several types of information are available:
Functions | Description |
---|---|
getUser() | User recovery |
setUser(user) | User Modification |
getAction() | Action performed recovery |
setAction(action) | Action performed modification |
getDescription() | Description retrieval |
setDescription(description) | Description modification |
getCreationDate() | Action completion date recovery |
setCreationDate(date) | Action completion date modification |
The actions (see
Action) supported for facts are:
CREATE
: Component creationUPDATE
: Component updateVERSION
: Creating a component versionASSIGN
: Assignment of a task to a userADD_CONTENT
: Adding an attachment to tasks, adding or updating content for documents and adding components to a folderDELETE_CONTENT
: Deleting an attachment to tasks, deleting content for documents and deleting components to a folderREVERT
: Restores a version of a document
Additional fields
In addition to information natively stored in the facts, additional fields can be stored (or simply displayed) using
Functions | Description |
---|---|
getUpdatedFields() | Fact fields recovery |
setUpdatedFields(fields) | Fact fields modification |
addUpdatedField(fields) | Add a field to the fact |
addUpdatedFields(fields) | Add several fields to the fact |
var fact = new Fact();
var field = new ResultField();
field.setName("RefClient");
field.setValue("1234");
fact.addUpdatedField(field)
Add facts
In certain business contexts, it may be necessary to build your own facts. To do this, several functions are available for this purpose:
To add new facts, it is first necessary to obtain a fact instance with one of the following constructors:
Functions | Description |
---|---|
new Fact(component) | Creating a fact from a component |
new Fact() | Creating an empty fact |
To modify a component’s history, you need to subscribe to the history opening feature:
var factAPI = JSAPI.get().getHelperFactory().getFactAPI();
factAPI.register(component.getId(), function(facts, callback){
//Manipulate facts of component
});
The facts
array provided as input to the subscription contains the facts determined natively by the application.
In order to modify the facts displayed to users, it is necessary to provide a modified array to the callback
provided:
var factAPI = JSAPI.get().getHelperFactory().getFactAPI();
factAPI.register(component.getId(), function(facts, callback){
var processed = new Array();
callback.onProcessed(processed);
});
FactFieldsConfiguration
.