Set UDF

Available from: Clarity LIMS v2.0.5

Often, a user would like to set or change the value of a UDF. If the UDF is accessible from the initial process URI, the setUDF script can be used.

Script Overview

The setUDF script allows several operations to take place, including - but not limited to the following:

  • Set a UDF on an output container to today's date.

  • Set a UDF on any sample associated with any input to a person's name.

  • Set a UDF on any output to a lab name (referred to as 'Account' in Clarity LIMS).

  • Set the input container name as a process level UDF.

  • Read a project UDF and set it on a sample.

Script Parameters

Parameter

Description

-u {username}

(Required) LIMS login username

-p {password}

(Required) LIMS login password

-i {URI}

(Required) LIMS process URI

-f {name}

(Required) UDF names

-t {XPath}

(Required) Path to the target object

-s {XPath}

(Optional) Path to the source element/attribute

-v {value}

(Required if the path to the source value is not provided, optional otherwise) UDF value

Examples

There are multiple ways to implement this script, as illustrated by the following examples.

Example 1

Set the UDF named MyUDF on any output containers to the date the process ran:

bash -l -c "/opt/gls/clarity/bin/java -jar /opt/gls/clarity/extensions/ngs-common/v5/EPP/ngs-extensions.jar \
script:setUDF \
-u {username} \
-p {password} \
-i {processURI:v2} \
-f 'MyUDF' \
-t '//output/@uri->//container/@uri' \
-s '//date-run'"
Example 2

Set the UDF named MyUDF on any sample associated with any input to the name of the technician:

bash -l -c "/opt/gls/clarity/bin/java -jar /opt/gls/clarity/extensions/ngs-common/v5/EPP/ngs-extensions.jar \
script:setUDF \
-u {username} \
-p {password} \
-i {processURI:v2} \
-f 'MyUDF' \
-t '//input/@uri->//sample/@uri' \
-s '//technician/*'"
Example 3

Set the UDF named MyUDF on any output to the name of the technician's lab:

bash -l -c "/opt/gls/clarity/bin/java -jar /opt/gls/clarity/extensions/ngs-common/v5/EPP/ngs-extensions.jar \
script:setUDF \
-u {username} \
-p {password} \
-i {processURI:v2} \
-f 'MyUDF' \
-t '//input/@uri' \
-s '//technician/@uri->//lab/@uri->//name'"
Example 4

Set the input container name as a process level UDF:

bash -l -c "/opt/gls/clarity/bin/java -jar /opt/gls/clarity/extensions/ngs-common/v5/EPP/ngs-extensions.jar \
script:setUDF \
-u {username} \
-p {password} \
-i {processURI:v2} \
-f 'FlowCellID' \
-t '/process/@uri' \
-s '//input/@uri->//container/@uri->//name'"
Example 5

Read a project UDF and set it on a sample:

/opt/gls/clarity/bin/java -jar /opt/gls/clarity/extensions/ngs-common/v5/EPP/ngs-extensions.jar \
script:setUDF \
-u {username} \
-p {password} \
-i {processURI:v2} \
-f 'Study' \
-t '//input/@uri->//sample/@uri' \
-s '//input/@uri->//sample/@uri->//project/@uri->/project/field[@name="Study"]'
Example 6

Read a parent process UDF and set it on a sample level UDF called Geneticist:

/opt/gls/clarity/bin/java -jar /opt/gls/clarity/extensions/ngs-common/v5/EPP/ngs-extensions.jar \
script:setUDF \
-u {username} \
-p {password} \
-i {processURI:v2} \
-f 'Geneticist' \
-t '//input/@uri->//sample/@uri' \
-s '//input/@uri->//parent-process/@uri->//technician/@uri->//initials'
Example 7

Read the Project name and set it on a sample level UDF called ProjectName:

/opt/gls/clarity/bin/java -jar /opt/gls/clarity/extensions/ngs-common/v5/EPP/ngs-extensions.jar \
script:setUDF \
-u {username} \
-p {password} \
-i {processURI:v2} \
-f 'ProjectName' \
-t '//input/@uri->//sample/@uri' \
-s '//input/@uri->//sample/@uri->//project/@uri->//name'

ℹ️ In the examples shown above, the paths may differ for your system. For example, the version number may differ. For Clarity LIMS 4 or before, the process URI token should be:

{processURI:v2:https} or {processURI:v2:http}

Rules & constraints

  • Both the target entity and (optionally) the source value are expressed as chains of XPath expressions (using -> as separators).

  • Even if you are using XPath to specify the source value, setUDF applies a single value per invocation to all target objects. It cannot apply different source values to different target objects.

  • You can use -z as an option when running the script to simulate the effects it would have. Note that even though an output identifying the target object(s) and the value that would be set is produced no changes are actually made.

Additional information

Other scripts you may find useful:

Last updated