# Remove Information from a Project

The following example shows you how to remove information from a project using Clarity LIMS and API (compatible with v2 r21 and later).

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**.

There are two types of custom fields:

* **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 user-defined field (UDF) / custom field named **Objective** is defined for projects.
* A project name that is unique and does not exist in the system.

### Code Example <a href="#example" id="example"></a>

This example does the following actions:

1. POST a new project to the LIMS, with a UDF / custom field value for **Objective**.
2. Remove a child XML node from the parent XML representing the project resource.
3. Update the project resource.

#### Step 1. POST a New Project with a UDF Value for Objective <a href="#step1" id="step1"></a>

First, set up the information required to perform a successful project POST. The project name must be unique.

```
// Determine project list's URI
String projectsListURI = "http://${hostname}/api/v2/projects"
 
def builder = new StreamingMarkupBuilder()
builder.encoding = "UTF-8"
openDate = "2017-08-24"
 
// Build a new project using Markup Builder
def projectDoc = builder.bind {
    mkp.xmlDeclaration()
    mkp.declareNamespace(prj: 'http://genologics.com/ri/project')
    mkp.declareNamespace(udf: 'http://genologics.com/ri/userdefined')
    'prj:project'{
        'name'(projectName)
        'open-date'(openDate)
        'researcher'(uri:"http://${hostname}/api/v2/researchers/1")
        'udf:field'(name:"Objective","To test httpPOST")
    }
}
// Post the new project
def projectNode = GLSRestApiUtils.xmlStringToNode(projectDoc.toString())
projectNode = GLSRestApiUtils.httpPOST(projectNode, projectsListURI, username, password)
println GLSRestApiUtils.nodeToXmlString(projectNode)
```

The **projectNode** should contain the response XML from the POST and resemble the following output:

```
<prj:project xmlns:prj="http://genologics.com/ri/project" uri="http://yourIPaddress/api/v2/projects/WOR512" limsid="WOR512">
  <name>httpPOST Project then remove nodes</name>
  <open-date>2017-08-24</open-date>
  <researcher uri="http://yourIPaddress/api/v2/researchers/1"/>
  <udf:field xmlns:udf="http://genologics.com/ri/userdefined" type="String" name="Objective">To test httpPOST</udf:field>
  <permissions uri="http://yourIPaddress/api/v2/permissions/projects/WOR512"/>
</prj:project>
```

#### Step 2. Remove Child XML Node from Parent XML Node <a href="#step2" id="step2"></a>

The following code removes the child XML node **\<udf:field>** from the parent XML node **\<prj:project>**:

```
// If projectNode is parentNode, remove the child udf:field
projectNode?.children()?.remove(projectNode.'udf:field'[0])
 
// Print the node that will be updated
println GLSRestApiUtils.nodeToXmlString(projectNode)
```

If multiple nodes of the same type exist, \[0] is the first item in this list of same typed nodes (eg, 0 contains 1st item, 1 contains 2nd item, 2 contains 3rd item, and so on).

To remove the 14th udf:field, you would use projectNode?.children()?.remove(projectNode.'udf:field'\[13])

### Attachments

RemoveChildNode.groovy:

{% file src="/files/dSPnFVo31BRWcQ7FEw9s" %}


---

# 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.claritylims.illumina.com/api-and-database/api-docs/cookbook/work-with-projects-and-accounts/remove-information-from-a-project.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.
