Adding result rows to a run

LabKey Support Forum
Adding result rows to a run Will Holtz  2014-07-01 10:35
Status: Closed
 
In the module based assay that I am working on, result rows correspond to measurements taken at time points. The duration between time points is relatively long and it can be useful to view a partial data analysis before all time points with in the run have occurred. I would like to allow users to input a subset of result rows before the run has completed and then later add additional result rows (perhaps multiple times). It appears the module based assay prohibits such a workflow. I tried using the javascript LABKEY.Query.insertRows() and LABKEY.Query.executeSql() functions, but insertRows seems locked down and executeSql appears to only do queries.

Is there some other way that I might be able to get this functionality within a module based assay? I guess I could always sidestep Labkey and have an external program insert rows, but that has downsides. I think I'll probably just not use assay functionality and build up from simpler structures within Labkey.

thanks,
-Will
 
 
kevink responded:  2014-07-01 16:09
Hi Will,

For file-based module assays, you can use the LABKEY.Experiment.saveBatch() method to add new data rows to an existing assay run. The saveBatch() API take a batch aka LABKEY.Exp.RunGroup object that contains an array of runs each of which contains an array of dataRows. For example, to add new data results to an existing run:

var assayId = <id of the assay>;
var batchId = <id of the batch previously imported>;

LABKEY.Experiment.loadBatch({
assayId: assayId,
batchId: batchId,
success: function (batch) {
// add a result row to an existing run
var row = {mydata: 100};
batch.runs[0].dataRows.push(row);

LABKEY.Experiment.saveBatch({
assayId: assayId,
batch: batch,
success: function (updatedBatch) { … }
});
}
});

For more on writing file-based module assays, see: https://www.labkey.org/wiki/home/Documentation/page.view?name=moduleassay

We'd love to follow up about the various different approaches to developing assays -- I'll send you an email off the board.

Thanks, Kevin