class WeakRecordKey extends RecordId
c154458 i538329@st .c369683 .i1843944 .i5876342@abcde
-
Weak record keys does not have check digits, unlike strong record keys.
-
Weak record keys can be ambiguous. Ambiguous weak record keys will cause RecordId.detect and RecordId.fromString to fail.
type WeakRecordKey.Parts = {
initialPeriod = false: boolean,
recordTypeCode: string,
recNum: string,
campusCode = null: null | string
}
Part | Description |
---|---|
initialPeriod |
|
recordTypeCode |
The 1 character code for the record type. |
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 weak record key via the parts
property, or you can get individual parts directly.
const weakRecordKey = new WeakRecordKey('c154458')
weakRecordKey.parts
// => { initialPeriod: false, recordTypeCode: 'c', recNum: '154458', campusCode: null }
weakRecordKey.initialPeriod // => false
weakRecordKey.recordTypeCode // => 'c'
weakRecordKey.recNum // => '154458'
weakRecordKey.campsuCode // => null
const weakRecordKey = new WeakRecordKey('.i5876342@abcde')
weakRecordKey.parts
// => { initialPeriod: true, recordTypeCode: 'c', recNum: '154458', campusCode: 'abcde' }
weakRecordKey.initialPeriod // => true
weakRecordKey.recordTypeCode // => 'c'
weakRecordKey.recNum // => '154458'
weakRecordKey.campsuCode // => 'abcde'
You can construct weak record keys from parts.
const weakRecordKey = new WeakRecordKey({ recordTypeCode: 'i', recNum: '1843944' })
weakRecordKey.parts
// => { initialPeriod: false, recordTypeCode: 'i', recNum: '1843944', campusCode: null }
weakRecordKey.toString() // => 'i1843944'
const weakRecordKey =
new WeakRecordKey({ initialPeriod: true, recordTypeCode: 'p', recNum: '5383293', campusCode: 'st' })
weakRecordKey.parts
// => { initialPeriod: true, recordTypeCode: 'p', recNum: '5383293', campusCode: 'st' }
weakRecordKey.toString() // => '.p5383293@st'
You can give an initialPeriod
option when converting to a weak record key. If you don’t, the initialPeriod
part of
the weak record key will be false
.
const recordId = new RelativeV4ApiUrl('v4/items/1843944')
recordId.convertTo(WeakRecordKey).parts
// => { initialPeriod: false, recordTypeCode: 'i', recNum: '1843944', campusCode: null }
recordId.convertTo(WeakRecordKey, { initialPeriod: false }).parts
// => { initialPeriod: false, recordTypeCode: 'i', recNum: '1843944', campusCode: null }
recordId.convertTo(WeakRecordKey, { initialPeriod: true }).parts
// => { initialPeriod: true, recordTypeCode: 'i', recNum: '1843944', campusCode: null }
initialPeriod | campusCode | Template |
---|---|---|
false |
null |
|
false |
not null |
|
true |
null |
|
true |
not null |
|
Part | Validation |
---|---|
recordTypeCode |
Is a valid record type code. Which record type codes are valid depends on the
|
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. |
Option | Description |
---|---|
apiCompatibleOnly |
If |