ftos.data.closeLastApprovedVersion
Closes an approved entity record version and redirects its references to a specified version draft.
This method transitions the record version currently in the Approved business workflow state to the Version Closed state. All references pointing to the closed version are redirected to the specified Version Draft record. This includes references from related versioned entities that have versioning temporarily disabled.
IMPORTANT!
The record's entity must be configured for versioning (see the Entity Cloning and Versioning documentation for details). Also, a version draft of the record must exist to receive the redirected references (see ftos.data.version for information on how to create a new record version).
The record's entity must be configured for versioning (see the Entity Cloning and Versioning documentation for details). Also, a version draft of the record must exist to receive the redirected references (see ftos.data.version for information on how to create a new record version).
IMPORTANT!
It is recommended to execute this method immediately before approving a new record version, preferably within the same transaction.
It is recommended to execute this method immediately before approving a new record version, preferably within the same transaction.
This is a data service method for business service components.
Syntax
Copy
ftos.data.closeLastApprovedVersion(recordId : string, versioningSettingName : string): void;
| Parameter | Type | Description |
|---|---|---|
recordId
|
string | The ID (primary key) of the version draft that will receive the relationships from the closed version. |
versioningSettingName
|
string | The name of the clone and version settings used to configure the entity's versioning. |
Examples
This example:
- Creates a new version draft of the current record using the ftos.data.version method and stores its ID in the myDraft variable.
- Uses the ftos.data.update method to redact the FirstName and LastName attributes of the draft record.
- Closes the currently approved version and redirects all references to the new draft.
- Uses the ftos.businessStatusWorkflow.update method to approve the draft.
Copy
var currentEntity = ftos.context.entityName;
var currentRecord = ftos.context.id;
// Create a new draft version of the current record based on the version_config clone and versioning settings
var myDraft = ftos.data.version(currentRecord, version_config);
// Redact the first name and last name in the draft
ftos.data.update(currentEntity, myDraft, { FirstName: 'Redacted', LastName: 'Redacted' });
// Close the previously approved version and redirect references to the draft
ftos.data.closeLastApprovedVersion(myDraft, version_config);
// Approve the draft
ftos.businessStatusWorkflow.update(currentEntity, myDraft, ftos.businessStatusWorkflow.getId(currentEntity, 'Approved'));