# Update Master Data

The users have two options on the View Master Data screen -

1. Disable/Enable Master Data
2. Edit Master Data

### Disable/Enable Master Data

* This option is dynamic, if the master data is currently disabled(computed through the "isActive" flag present in every master data) Enable option is shown and vice-versa.
* Update Master data API is called with the updated value of "isActive" flag and a respective toast message is shown to the user
* As soon as the API responds, this option is updated according to the new value of "isActive" flag.
* Pls refer to the end of this page for updated API details

### Edit Master Data

* When the user clicks on this option, the screen redirects to the Edit master data screen.
* This screen is similar to the add master data screen, but all the fields are pre-populated with previous data.
* Users can make changes to the master data.
* Once the user clicks on the Submit button, validations are run in UI (specified in schema). If the validations are passed update master data API is called and a toast message is shown. After 5 seconds the user is automatically redirected to the view screen, where the updated data is reflected.
* If the validations fail, the respective error message is shown below the target field for which validations failed.
* The same role action mapping rules apply here as mentioned in the Add Master data page.

### Update Master Data API

Refer to the curl below to update the master data API. It is very similar to the Create Master Data. (Notice the URL is unique to the schema for which the master data belongs, similar to add).

{% code lineNumbers="true" %}

```
curl 'http://localhost:3000/mdms-v2/v2/_update/Trade.Validations' \
  -H 'Accept: application/json, text/plain, */*' \
  -H 'Accept-Language: en-US,en;q=0.9' \
  -H 'Connection: keep-alive' \
  -H 'Content-Type: application/json;charset=UTF-8' \
  -H 'Origin: http://localhost:3000' \
  -H 'Referer: http://localhost:3000/workbench-ui/employee/workbench/mdms-edit?moduleName=Trade&masterName=Validations&uniqueIdentifier=sfd' \
  -H 'Sec-Fetch-Dest: empty' \
  -H 'Sec-Fetch-Mode: cors' \
  -H 'Sec-Fetch-Site: same-origin' \
  -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36' \
  -H 'sec-ch-ua: "Chromium";v="116", "Not)A;Brand";v="24", "Google Chrome";v="116"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "Windows"' \
  --data-raw '{"Mdms":{"id":"661b4560-a0ec-4930-a8c2-c84d643b361f","tenantId":"pb","schemaCode":"Trade.Validations","uniqueIdentifier":"sfd","data":{"name":"sfd","dropdownField":"70-90"},"isActive":true,"auditDetails":{"createdBy":"aeb85b37-c996-4218-bdca-1b00cc268f2f","lastModifiedBy":"aeb85b37-c996-4218-bdca-1b00cc268f2f","createdTime":1694161642579,"lastModifiedTime":1694161642579}},"RequestInfo":{"apiId":"Rainmaker","authToken":"5bbfa93c-adc2-42b2-992e-a708a83cb2cf","userInfo":{"id":80234,"uuid":"aeb85b37-c996-4218-bdca-1b00cc268f2f","userName":"WBQA","name":"LOC","mobileNumber":"9999991942","emailId":null,"locale":null,"type":"EMPLOYEE","roles":[{"name":"MDMS ADMIN","code":"MDMS_ADMIN","tenantId":"pb"},{"name":"Super User","code":"SUPERUSER","tenantId":"pb"},{"name":"Localisation admin","code":"LOC_ADMIN","tenantId":"pb"},{"name":"Employee","code":"EMPLOYEE","tenantId":"pb"}],"active":true,"tenantId":"pb","permanentCity":null},"msgId":"1694163335209|en_IN","plainAccessRequest":{}}}' \
  --compressed
```

{% endcode %}

Sample request body for update:

{% code lineNumbers="true" %}

```
{
    "Mdms": {
        "id": "661b4560-a0ec-4930-a8c2-c84d643b361f",
        "tenantId": "pb",
        "schemaCode": "Trade.Validations",
        "uniqueIdentifier": "sfd",
        "data": {
            "name": "sfd",
            "dropdownField": "70-90"
        },
        "isActive": true,
        "auditDetails": {
            "createdBy": "aeb85b37-c996-4218-bdca-1b00cc268f2f",
            "lastModifiedBy": "aeb85b37-c996-4218-bdca-1b00cc268f2f",
            "createdTime": 1694161642579,
            "lastModifiedTime": 1694161642579
        }
    },
    "RequestInfo": {
        "apiId": "Rainmaker",
        "authToken": "5bbfa93c-adc2-42b2-992e-a708a83cb2cf",
        "userInfo": {
            "id": 80234,
            "uuid": "aeb85b37-c996-4218-bdca-1b00cc268f2f",
            "userName": "WBQA",
            "name": "LOC",
            "mobileNumber": "9999991942",
            "emailId": null,
            "locale": null,
            "type": "EMPLOYEE",
            "roles": [
                {
                    "name": "MDMS ADMIN",
                    "code": "MDMS_ADMIN",
                    "tenantId": "pb"
                },
                {
                    "name": "Super User",
                    "code": "SUPERUSER",
                    "tenantId": "pb"
                },
                {
                    "name": "Localisation admin",
                    "code": "LOC_ADMIN",
                    "tenantId": "pb"
                },
                {
                    "name": "Employee",
                    "code": "EMPLOYEE",
                    "tenantId": "pb"
                }
            ],
            "active": true,
            "tenantId": "pb",
            "permanentCity": null
        },
        "msgId": "1694163335209|en_IN",
        "plainAccessRequest": {}
    }
}

```

{% endcode %}


---

# 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/update-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.
