# Validating Process/Step Level UDFs

In this example, the protocol step is configured to invoke a script that is triggered when the user exits the step's **Record Details** screen.

#### Parameters

The EPP command is configured to pass the following parameters to the script:

<table data-header-hidden><thead><tr><th width="107"></th><th width="336"></th><th align="right"></th></tr></thead><tbody><tr><td>-l</td><td>The limsid of the process invoking the script (Required)</td><td align="right"></td></tr><tr><td>-u</td><td>The username of the current user (Required)</td><td align="right"></td></tr><tr><td>-p</td><td>The password of the current user (Required)</td><td align="right"></td></tr><tr><td>-f</td><td>The names(s) of the UDF(s) that should be considered mandatory</td><td align="right">Multiple UDF names should be separated by a comma</td></tr></tbody></table>

An example of the full syntax to invoke the script is as follows:

{% code overflow="wrap" %}

```
/usr/bin/python /opt/gls/clarity/customextensions/checkprocessFields.py -l 122-7953 -u admin -p securepassword -f 'field Name 1, field Name 2, field Name N' 
```

{% endcode %}

### User Interaction

When the lab scientist attempts to exit the **Record Details** screen, the script is invoked and the UDF names specified in the -f parameter will be checked to see that they have been populated. If they ALL have been, the script issues no message, and the process will continue as normal. If however, SOME of the UDFs have not been populated, a message will be displayed to the user indicating which mandatory fields need to be populated, and the user will be unable to move forward until all the specified fields have been populated.

### About the Code

The method of central interest in the script is **checkFields()**. The method in turn carries out several operations:

1. The list of fields passed to the script *via* the -f parameter is broken into its component UDF names
2. For each UDF name in the list, the corresponding value is checked via the API, and if the value is empty, the UDF name is noted as absent
3. If any UDF names are noted as being absent, an error dialog will be displayed to the user.

### Assumptions and Notes

* Both of the attached files are placed on the LIMS server, in the **/opt/gls/clarity/customextensions** folder.
* The HOSTNAME global variable needs to be updated so that it points to your Clarity LIMS server.
* The example code is provided for illustrative purposes only. It does not contain sufficient exception handling for use 'as is' in a production environment.
* If required, this script could be enhanced so that it not only checked to see that the UDFs had been populated, but that their values also matches a regexp pattern for additional validation.

### Attachments

checkprocessFields.py:

{% file src="/files/8Eh5v8ddYBACseDh3ThD" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.connected.illumina.com/clarity-lims/api-and-database/api-docs/application-examples/scripts-that-validate-step-contents/page-14.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
