# Search Master Data

## Overview

## Search Master Data Flow

* Users can click on the specific master name from the dropdown on the Manage Master Data screen to select the master data.&#x20;
* Users are redirected to the Search Master Data screen (of the selected master) screen as soon as a master is selected.
* By default, the data present in that master is shown in the Results table.
* Users can search master data using the following input parameters -
  1. Field
  2. Value
  3. is Active

<mark style="color:red;">Note -> Search with field and value is considered as one parameter. Make sure to enter both in order to search master data.</mark>

* 'isActive' is a Boolean parameter which results in either active or inactive master data. All master data contain this field by default.
* For the time being, master data search is allowed with string fields and the isActive flag.&#x20;
* Search results are filtered by string type and isActive before getting rendered in the table.

### Search Schemas API

The master and module dropdowns on the manage master screen are populated on the basis of the responses from the schema search. Refer to the below curl for details:

Use the below parameters to search for the schemas -

1. tenantId
2. limit
3. offset&#x20;
4. codes -> list of schema codes

{% code lineNumbers="true" %}

```
curl --location 'http://localhost:8094/mdms-v2/schema/v1/_search' \
--header 'Content-Type: application/json' \
--data '{
    "RequestInfo": {
        "apiId": "asset-services",
        "ver": null,
        "ts": null,
        "action": null,
        "did": null,
        "key": null,
        "msgId": "search with from and to values",
        "authToken": "dfcca143-b5a6-4726-b5cd-c2c949cb0f2b",
        "correlationId": null,
        "userInfo": {
            "id": "1",
            "userName": null,
            "name": null,
            "type": null,
            "mobileNumber": null,
            "emailId": null,
            "roles": null
        }
    },
    "SchemaDefCriteria": {
        "tenantId": "pb",
        "codes": [
            "Trade.Fields"
        ],
        "limit":50
    }
}'
```

{% endcode %}

### Search Master Data For Specific Schema API&#x20;

Users are redirected to the search master data screen once a specific master is selected from the manage master data screen.

Refer to the below API curl to search for the master data -

{% code lineNumbers="true" %}

```
curl --location 'http://localhost:8094/mdms-v2/v2/_create/common-masters.Sample' \
--header 'Content-Type: application/json' \
--data '{
  "RequestInfo": {
    "apiId": "asset-services",
    "ver": null,
    "ts": null,
    "action": null,
    "did": null,
    "key": null,
    "msgId": "search with from and to values",
    "authToken": "dfcca143-b5a6-4726-b5cd-c2c949cb0f2b",
    "correlationId": null,
    "userInfo": {
      "id": "1",
      "userName": null,
      "name": null,
      "type": null,
      "mobileNumber": null,
      "emailId": null,
      "roles": null
    }
  },
  "Mdms": {
    "tenantId": "pg",
    "schemaCode": "common-masters.Sample",
    "uniqueIdentifier": "aa4d8d08-658b-45c1-af4d-d57428fa5e52",
    "data": {
                "id": "sdfljksd",
                "code": "testtcode",
                "name": "nameeee",
                "description": "descccc"
            },
    "isActive": true
  }
}'

```

{% endcode %}

The parameters here are used to search for the master data. Refer to the request body object below.

{% code lineNumbers="true" %}

```
 {
    "tenantId": "pg",
    "schemaCode": "common-masters.Sample",
    "uniqueIdentifier": "aa4d8d08-658b-45c1-af4d-d57428fa5e52",
    "data": {
                "id": "sdfljksd",
                "code": "testtcode",
                "name": "nameeee",
                "description": "descccc"
            },
    "isActive": true
  }

```

{% endcode %}

The "data" object holds the field-value pairs used to search for master data within a specific master. The "uniqueIdentifier" is a backend-generated ID for each master data.


---

# 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://workbench.digit.org/setup/configurations/workbench-ui/manage-master-data/search-master-data.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.
