> For the complete documentation index, see [llms.txt](https://docs.digit.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.digit.org/complaints-management/cms-v2.11/deploy/customise/backend/add-new-fields.md).

# Add New Fields

## Overview

This guide walks you through the **end-to-end process** of introducing a new field (e.g., `landmark`) in the **CMS service module**, starting from backend model changes to data persistence and validations.

Adding a new field typically involves changes across multiple layers:

* Java models (domain classes)
* Validation and enrichment logic
* Row mapping from DB
* Persister and indexer configurations

This ensures the field is:

* Captured in incoming requests
* Validated or enriched if needed
* Persisted to the database
* Indexed for search
* Returned in query results

***

## Steps&#x20;

{% stepper %}
{% step %}

### Add a field in the model

In `Service.java` (or the appropriate domain class):

```java
private String landmark;
```

{% endstep %}

{% step %}

### Add validation (optional)

In the `validateCreate()` method inside the Validator class:

```java
if (request.getLandmark() == null) {
    throw new CustomException("PGR.LANDMARK_REQUIRED", "Landmark is required");
}
```

{% endstep %}

{% step %}

### Enrich the Request (optional)

In `enrichCreateRequest()` method:

```java
if (request.getLandmark() == null) {
    request.setLandmark("Default");
}
```

{% endstep %}

{% step %}

### Map DB Result (RowMapper)

In `PGRRowMapper.java`:

```java
service.setLandmark(rs.getString("landmark"));
```

{% endstep %}

{% step %}

### Update Persister Configuration

In `persister.yml`, under `save-pgr-request` and `update-pgr-request` topics:

```yaml
- jsonPath: $.Service.landmark
  dbColumn: landmark
  type: STRING
```

👉 After updating, **restart the Persister service**.
{% endstep %}

{% step %}

### Update Persister Configuration

In `indexer.yml`, under `save-pgr-request` and `update-pgr-request` topics:

```yaml
- jsonPath: $.Service.landmark
  dbColumn: landmark
  type: STRING
```

👉 After updating, **restart the Indexer service**.
{% endstep %}

{% step %}

### Add to Search Query (Optional)

If you want to search/filter by `landmark`:

* Update the query in `PGRQueryBuilder.java`
* Add it to the parameter map

Your new field is now fully integrated into the CMS backend — from request to persistence.
{% endstep %}
{% endstepper %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.digit.org/complaints-management/cms-v2.11/deploy/customise/backend/add-new-fields.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
