class RecordNumber extends RecordId
164905 1666521 560184@fh 1462119@9qut0
-
Record numbers are ambiguous by themselves, because they do not identify the record type. If you want to translate from a record number, you will need to specify which type of record it is.
-
Sometimes the term record number in Sierra’s documentation actually means what
sierra-record-id
calls a weak record key or a a strong record key. -
A record number is called a record id in the Sierra API documentation. Although sometimes Sierra produces a record id that is actually an absolute v4 API URL.
type RecordNumber.Parts = {
recNum: string,
campusCode = null: null | string
}
Part | Description |
---|---|
recNum |
The actual number part of the record id. |
campusCode |
The 1-5 character code for a virtual record’s campus/location.
|
You get the parts of a record number via the parts
property, or you can get individual parts directly.
const recordNumber = new RecordNumber('3696836')
recordNumber.parts // => { recNum: '3696836', campusCode: null }
recordNumber.recNum // => '3696836'
recordNumber.campsuCode // => null
const recordNumber = new RecordNumber('587634@abcde')
recordNumber.parts // => { recNum: '587634', campusCode: 'abcde' }
recordNumber.recNum // => '587634'
recordNumber.campsuCode // => 'abcde'
You can construct record numbers from parts.
const recordNumber = new RecordNumber({ recNum: '3696836' })
recordNumber.parts // => { recNum: '3696836', campusCode: null }
recordNumber.toString() // => '3696836'
const recordNumber = new RecordNumber({ recNum: '587634', campusCode: 'abcde' })
recordNumber.parts // => { recNum: '587634', campusCode: 'abcde' }
recordNumber.toString() // => '587634@abcde'
Because a record number does not have a record type char, you have to give a recordTypeCode
option when converting
from a RecordNumber
.
new RecordNumber('587634@abcde').convertTo(WeakRecordKey, { recordTypeCode: 'p' }).toString()
// => 'p587634@abcde'
new RecordNumber('587634@abcde').convertTo(WeakRecordKey) (1)
-
Throws an error because the
recordTypeCode
options is missing.
You will loose the record type code when converting to a record number. This means you cannot simply convert back and forth between record numbers, like you can with other kinds of record id.
(
new WeakRecordKey('i587634@abcde')
.convertTo(StrongRecordKey)
.convertTo(WeakRecordKey) // (1)
)
(
new WeakRecordKey('i587634@abcde')
.convertTo(RecordNumber)
.convertTo(WeakRecordKey) // (2)
)
(
new WeakRecordKey('i587634@abcde')
.convertTo(RecordNumber)
.convertTo(WeakRecordKey, { recordTypeCode: 'i' }) // (3)
)
-
This will succeed and you will end up at a weak record key equivalent to the one you started with.
-
This will result in an error being thrown because once you have converted to a record number, you loose the fact that you started with a weak record key for an item record.
-
This will succeed because it supplies the record type code needed to convert from a record number.
Template for non-virtual record ids: ${recNum}
Template for virtual record ids: ${recNum}@${campusCode}
Part | Validation |
---|---|
recNum |
Is 6 or 7 digits and doesn’t have any zeros before the first non-zero. |
campusCode |
If not null, is 1-5 alphanumeric characters. |
There are no options when validating a record number.