eLabSDK.Experiment.Section.Sample

Functions

NameDescription
addSamples(sampleIDs)Add samples to this sample section.

This adds one or more samples to a SAMPLESIN or SAMPLESOUT section in an experiment. The
samples are linked to the section and will appear in the experiment's sample list. The
operation is asynchronous and fires the onSampleAdded event when complete. Use this to
programmatically associate samples with experiments, such as documenting input materials
(SAMPLESIN) or products/outputs (SAMPLESOUT).

Events

addSamples(sampleIDs)

Add samples to this sample section.

This adds one or more samples to a SAMPLESIN or SAMPLESOUT section in an experiment. The
samples are linked to the section and will appear in the experiment's sample list. The
operation is asynchronous and fires the onSampleAdded event when complete. Use this to
programmatically associate samples with experiments, such as documenting input materials
(SAMPLESIN) or products/outputs (SAMPLESOUT).

Kind: global function

ParamTypeDescription
sampleIDsArray.<number>Array of numeric sample IDs to add to this section

Example

// Add samples to SAMPLESIN section
var experiment = new eLabSDK.Experiment({
  experimentID: 123,
  onLoaded: function() {
    var sampleSection = this.sections[0];
    if (sampleSection instanceof eLabSDK.Experiment.Section.Sample) {
      sampleSection.onSampleAdded(function() {
        console.log('Samples added to experiment');
        alert('Input samples linked successfully');
      });
      
      sampleSection.addSamples([456, 457, 458]);
    }
  }
});

Example

// Create section and add samples
var experiment = new eLabSDK.Experiment({
  experimentID: 789,
  onLoaded: function() {
    var exp = this;
    this.addSection({
      sectionHeader: 'Input Materials',
      sectionType: 'SAMPLESIN',
      onCreated: function() {
        var sampleSection = exp.getSection(this.options.sectionID);
        
        sampleSection.onSampleAdded(function() {
          console.log('Input samples linked');
        });
        
        sampleSection.addSamples([101, 102, 103]);
      }
    });
  }
});

Example

// Add output samples (SAMPLESOUT)
var experiment = new eLabSDK.Experiment({
  experimentID: 321,
  onLoaded: function() {
    var exp = this;
    this.addSection({
      sectionHeader: 'Output Products',
      sectionType: 'SAMPLESOUT',
      onCreated: function() {
        var outputSection = exp.getSection(this.options.sectionID);
        
        // Create output samples first
        eLabSDK.Inventory.Sample.create({
          name: 'Product Sample',
          sampleTypeID: 555,
          fnWhenReady: function(config, sample) {
            // Add newly created sample to output section
            outputSection.addSamples([sample.sampleID]);
          }
        });
      }
    });
  }
});

Example

// Add samples from user selection
var sampleSection = experiment.getSection(777);

// User selects samples via custom UI
var selectedSampleIDs = [100, 101, 102, 103];

sampleSection.onSampleAdded(function() {
  console.log('Added ' + selectedSampleIDs.length + ' samples');
  refreshExperimentView();
});

sampleSection.addSamples(selectedSampleIDs);

"onSampleAdded" (object)

Kind: event emitted

ParamType
objecteLabSDK.Experiment.ContentUpdater.Sample

Example

var sampleSection = experiment.sections[0];
     sampleSection.onSampleAdded(function(){
         alert('samples are added!');
     });
     sampleSection.addSamples([1234]);

© 2023 eLabNext