Shorten Condition Record Validity Interval

Available since version 16.0

The conditionRecordHelper.shortenValidTo(...) method allows you to shorten (expire) the validity of an existing condition record by updating only its validTo date, without changing its original validFrom or business values.

The method finds the matching record, removes the original, and creates a new record with an updated validTo date (and otherwise identical data). It can only change the expiration date to an earlier date (i.e., cannot prolong the validity).

The shorten operation is applied before Condition Record splicing and superseding logic is executed. This means that if there are already other Condition Records for the same keys, the new validTo you pass to shortenValidTo() will affect how subsequent splicing resolves overlaps. When you choose the new validTo value, take into account how the shortened interval should interact with any existing overlapping Condition Records (for example, which records should remain active, be truncated, or be superseded).

Method Reference

conditionRecordHelper.shortenValidTo(...)

A helper method available in the Groovy context for condition record processing.

Input Parameters

The method takes a map with the same input structure as conditionRecordHelper.addOrUpdate(...), but only a subset of fields is strictly required to locate the existing record:

  • Key elements – e.g. key1, possibly additional keys depending on your condition record set.

  • conditionRecordSetId – the ID of the condition record set where the record is stored.

  • validFrom – the original validFrom of the existing record; there should be only one record with this combination of keys and validFrom.

  • validTo – the new, earlier validTo value that should replace the current validTo ("shorten from the right").

All other values are handled the same way as with conditionRecordHelper.addOrUpdate(...) and are preserved in the newly created record.

Behavior Details

Record Replacement

When a matching record is found and the new validTo is shorter than the current validTo:

  • The existing record is removed (or superseded, depending on configuration).

  • A new record is created with:

    • The same key values.

    • The same validFrom.

    • The new, earlier validTo.

    • The same business values (for example, price values) as the original record.

  • The status of the superseded record will be set to shortened.

Supersede Compatibility

If supersede logic is enabled globally or for the job (via splicing options):

  • shortenValidTo(...) respects supersede behavior instead of hard-deleting the original record.

  • The superseded record is correctly replaced and marked according to the superseding rules.

No-op Conditions

The operation becomes a no-op (no change) in the following cases:

  • No matching record is found for the provided keys, conditionRecordSetId, and validFrom.

  • The new validTo is not earlier than the existing validTo (equal or greater).

  • The new validTo is earlier than validFrom.

In such cases:

  • No exception is thrown.

  • Only an optional DEBUG-level log entry is written to the server log.

Set / Reset Compatibility

Standard set/reset operations (such as reset("attribute10")) continue to work correctly with the records updated via shortenValidTo(...).

When you call withSplicingOption().set(...) or withSplicingOption().reset(...) on a record that has been shortened using shortenValidTo(), you must pass key values that match the shortened record, including the new validTo date. In other words, the key values (such as key1..keyN, validFrom, validTo, and conditionRecordSetId) used for the set / reset operation must use the updated validTo produced by the shorten operation; otherwise, the splicing job will not target the intended shortened record.

Usage Examples

Example Data

Assume the following existing condition record:

typedId

key1

conditionRecordSetId

validFrom

validTo

77.CRCI1

Company 1

7

2025-07-07

2025-07-30

Case 1 – Superseding Off

Groovy
conditionRecordHelper.shortenValidTo([
    "key1"               : "Company 1",
    "validFrom"          : "2025-07-07",
    "validTo"            : "2025-07-16",
    "conditionRecordSetId": 7
])

Result:

typedId

key1

conditionRecordSetId

validFrom

validTo

770.CRCI1

Company 1

7

2025-07-07

2025-07-16

The original record is replaced with a new one that has the shortened validTo date, preserving keys, validFrom, and values.

Case 2 – Superseding On

Groovy
conditionRecordHelper.shortenValidTo([
    "key1"               : "Company 1",
    "validFrom"          : "2025-07-07",
    "validTo"            : "2025-07-16",
    "conditionRecordSetId": $crsId
])

conditionRecordHelper.withSplicingOption().setSupersedingOn()

Result: Superseding logic applies; the shortened record is created and the original is tracked according to supersede configuration.

typedId

key1

conditionRecordSetId

validFrom

validTo

770.CRCI1

Company 1

7

2025-07-07

2025-07-16

333.CRCIH1

Company 1

7

2025-07-07

2025-07-30

In this mode, the shortening respects existing supersede/splicing rules instead of directly deleting the original record.