eLabSDK2.Inventory.SampleType
Hierarchy
-
↳
SampleType
Methods
getSampleTypeMetaBySampleTypeMetaID
Static getSampleTypeMetaBySampleTypeMetaID(sampleTypeMetaId): any
Get a specific metadata field definition by its unique ID.
This retrieves a single metadata field configuration by its unique identifier. Use this when you need detailed information about a specific metadata field, such as its name, data type, validation rules, or which sample type it belongs to. This is useful when processing form data, validating fields, or displaying field-specific information.
Parameters
| Name | Type | Description |
|---|---|---|
sampleTypeMetaId | number | The unique ID of the metadata field to retrieve. |
Returns
any
A Promise that resolves to the SampleTypeMetaInterface object for the specified field.
Example
// Get a specific metadata field by ID
const metaFieldId = 42;
const metaField = await eLabSDK2.Inventory.SampleType.getSampleTypeMetaBySampleTypeMetaID(metaFieldId);
console.log(`Field: ${metaField.name}, Type: ${metaField.fieldType}`);Example
// Validate a field based on its configuration
const metaFieldId = 42;
const metaField = await eLabSDK2.Inventory.SampleType.getSampleTypeMetaBySampleTypeMetaID(metaFieldId);
const userInput = document.getElementById('field-input').value;
if (metaField.required && !userInput) {
alert(`${metaField.name} is required`);
}Example
// Display field information in a form
const metaFieldId = 42;
const metaField = await eLabSDK2.Inventory.SampleType.getSampleTypeMetaBySampleTypeMetaID(metaFieldId);
const label = document.createElement('label');
label.textContent = `${metaField.name}${metaField.required ? ' *' : ''}`;getSampleTypeMetas
Static getSampleTypeMetas(): SampleTypeMetaInterface[]
Get all metadata field definitions for all sample types in the system.
This retrieves every metadata field configuration across all sample types. Each metadata field object includes information about which sample type it belongs to, the field name, data type, and validation rules. Use this to get a complete overview of all custom fields, build global field management interfaces, or analyze metadata field usage across the system.
Returns
SampleTypeMetaInterface[]
An array of all SampleTypeMetaInterface objects across all sample types, or an empty array if none exist.
Example
// Get all metadata fields across all sample types
const allMetaFields = eLabSDK2.Inventory.SampleType.getSampleTypeMetas();
console.log(`Total metadata fields defined: ${allMetaFields.length}`);Example
// Find all sample types that use a specific field name
const allMetaFields = eLabSDK2.Inventory.SampleType.getSampleTypeMetas();
const concentrationFields = allMetaFields.filter(field =>
field.name.toLowerCase().includes('concentration')
);
console.log(`${concentrationFields.length} sample types track concentration`);Example
// Group metadata fields by sample type
const allMetaFields = eLabSDK2.Inventory.SampleType.getSampleTypeMetas();
const fieldsBySampleType = {};
allMetaFields.forEach(field => {
if (!fieldsBySampleType[field.sampleTypeID]) {
fieldsBySampleType[field.sampleTypeID] = [];
}
fieldsBySampleType[field.sampleTypeID].push(field);
});
console.log('Fields by sample type:', fieldsBySampleType);getSampleTypeMetasForSampleType
Static getSampleTypeMetasForSampleType(sampleTypeID): SampleTypeMetaInterface[]
Get all metadata field definitions for a specific sample type.
This retrieves the custom metadata fields configured for a given sample type. Metadata fields define the additional information that can be captured for samples of this type (e.g., concentration, buffer, purity, expiration date, etc.). Each metadata field includes configuration like field name, type, required status, and validation rules. Use this to dynamically build forms, validate input, or display sample type-specific fields.
Parameters
| Name | Type | Description |
|---|---|---|
sampleTypeID | number | The sample type ID to retrieve metadata fields for. |
Returns
SampleTypeMetaInterface[]
An array of SampleTypeMetaInterface objects defining the metadata fields, or an empty array if none are configured.
Example
// Get metadata fields for a specific sample type
const sampleTypeId = 5; // Antibody sample type
const metaFields = eLabSDK2.Inventory.SampleType.getSampleTypeMetasForSampleType(sampleTypeId);
metaFields.forEach(field => {
console.log(`${field.name} (${field.fieldType}), Required: ${field.required}`);
});Example
// Dynamically build a form based on metadata fields
const metaFields = eLabSDK2.Inventory.SampleType.getSampleTypeMetasForSampleType(sampleTypeId);
metaFields.forEach(field => {
addFormField(field.name, field.fieldType, field.required);
});Example
// Check if a sample type has specific metadata
const metaFields = eLabSDK2.Inventory.SampleType.getSampleTypeMetasForSampleType(sampleTypeId);
const hasConcentration = metaFields.some(field => field.name === 'Concentration');
if (hasConcentration) {
console.log('This sample type tracks concentration');
}© 2023 eLabNext
Updated about 5 hours ago