Skip to content
This repository has been archived by the owner on Feb 2, 2019. It is now read-only.

Latest commit

 

History

History
174 lines (122 loc) · 4.41 KB

record-number.asciidoc

File metadata and controls

174 lines (122 loc) · 4.41 KB

RecordNumber

Overview

class RecordNumber extends RecordId

Examples of record number strings
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.

Parts

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. null if the record id isn’t for a virtual record. Defaults to null.

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'

Converting

From a record number

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)
  1. Throws an error because the recordTypeCode options is missing.

To a record number

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)
)
  1. This will succeed and you will end up at a weak record key equivalent to the one you started with.

  2. 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.

  3. This will succeed because it supplies the record type code needed to convert from a record number.

Stringifying

Template for non-virtual record ids: ${recNum}

Template for virtual record ids: ${recNum}@${campusCode}

Validation

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.