Update UDF/Custom Field Information with Batch Operations

As previously shown in Update UDF/Custom Field Values for a Derived Sample Output, you can update the user-defined fields/custom fields of the derived samples (referred to as analytes in the API) generated by a step. This example uses batch operations to improve the performance of that script.

As of Clarity LIMS v5, the term user-defined field (UDF) has been replaced with custom field in the user interface. However, the API resource is still called UDF.

  • Master step fields—Configured on master steps. Master step fields only apply to the following:

    • The master step on which the fields are configured.

    • The steps derived from those master steps.

  • Global fields—Configured on entities (eg, submitted sample, derived sample, measurement, etc.). Global fields apply to the entire Clarity LIMS system.

Prerequisites

Before you follow the example, make sure that you have the following items:

  • A global custom field named Library Size that on the Derived Sample object.

  • A configured Library Prep step that applies Library Size to generated derived samples.

  • A Library Prep step that has been run and has generated derived samples.

  • A compatible version of API (v2 r21 or later).

Code Example

In Clarity LIMS, the Record Details screen displays the information about the derived samples generated by a step. You can view the global fields associated with the derived samples in the Sample table.

The screenshot below shows the Library Size values for the derived samples.

Derived sample information is stored in the API in the analyte resource. Step information is stored in the process resource. Each global field value is stored as a udf.

An analyte resource contains specific derived sample details that are recorded in lab steps. Those details are typically stored in global fields, configured in the LIMS on the Derived Sample object and then associated with the step. When you update the information for a derived sample by updating the analyte API resource, only the global fields that are associated with the step can be updated.

Step 1. Retrieve the Process Information

To retrieve the process information, you can perform a GET on the created process URI, as follows:

processURI = "http://${hostname}/api/v2/processes/${processLIMSID}"
process = GLSRestApiUtils.httpGET(processURI, username, password)

Step 2. Retrieve URIs of Output Analytes

You can now collect all of the output analytes and harvest their URIs:

Step 3. Retrieve Analytes

After you have collected the output analyte URIs, you can retrieve the analytes with a batchGET() operation. The URIs must be unique for the batch operations to succeed.

def outputNodes = GLSRestApiUtils.batchGET(outputAnalyteURIs, username, password)

Step 4. Set Analyte Library Size UDF

You can now iterate through our retrieved list of analytes and set each analytes 'Library Size' UDF to 25.

outputNodes.each {
    GLSRestApiUtils.setUdfValue(it, 'Library Size', '25')
}

Step 5. Update Analytes

To update the analytes in the system, call batchPUT(). It will attempt to call a PUT for each node in the list. (Note that each node must be unique.)

GLSRestApiUtils.batchPUT(outputNodes, username, password)

Expected Output and Results

In the Record Details screen, the Sample table now shows the updated Library Size.

Attachments

UsingBatchPut.groovy:

Last updated