Assigning Samples to Workflows
You can use the API (v2 r21 and later) to automate the process of assigning samples to a workflow. This example shows how to create the required XML. The example also provides a brief introduction on how to use the route/artifacts endpoint, which is the endpoint used to perform the sample assignment.
The example takes two samples that exist in Clarity LIMS and assigns each of them to a different workflow.
Code example
Step 1. Define Assignment Endpoint URI
Define the assignment endpoint URI using the following example. The assignment endpoint allows you to assign the artifacts to the desired workflow.
Step 2. Retrieve the Samples' Base Artifact URIs
You can also retrieve the base artifact URIs of the samples using the following example:
Step 3. Gather Workflow URIs
Use the following example to gather the workflow URIs:
Step 4. Construct and POST the XML
Next, you can construct the XML that is posted to perform the workflow assignment. You can do this construction by using the StreamingMarkupBuilder and the following example.
Assign the analyte (derived sample) artifact of the sample to a workflow as follows.
Create an assign tag with the URI of the destination workflow as an attribute.
Create an artifact tag inside the assign tag with the URI of the analyte as an attribute.
After the assignment XML is defined, you can POST it to the API. This POST performs the sample assignment.
Expected Output and Results
After the script has run, the samples display in the first step of the first protocol in the specified workflows.
Attachments
AssigningArtifactsToWorkflows.groovy:
Last updated