knowledgecenter-breadcrum

Knowledge Center

15 Jul, 2026

Recovering a Deleted Option Set(Choice) Value in Dynamics 365 Using Web API

Posted on 15 Jul, 2026 by Shoaib Khan, Posted in Microsoft Power Platform Power Apps Dataverse Power Platform Dynamics 365 Web Api Dynamics 365 Blog

Blogs

The Problem

Recently, we faced an interesting issue while working with the Status Reason (statuscode) field on the Contact table.

Our environments were configured as follows:

Development – Unmanaged
UAT – Managed

Unfortunately, someone accidentally deleted one of the Status Reason values from the Contact table in the Development environment.

Normally, you would think creating the option again would solve the problem. However, that's where the real challenge began.

 

Why Creating a New Status Reason Didn't Work

When you create a new Status Reason value from the Maker Portal or Solution Explorer:

  • Dataverse automatically assigns a new integer value.
  • You cannot manually specify the option value for some OOB Option set fields.
  • The deleted value cannot be recreated with its original numeric value.

For example:

Before Deletion  After Creating Again
Pending Verification = 3  Pending Verification = 800860001

This created a deployment problem.

The UAT managed solution was still expecting the original value (3), but Development now had a different value (800860001).

Changing the value manually isn't supported, and Dataverse doesn't provide a way to override the automatically assigned value.

At this point, we were stuck.

 

The Solution

After some research, we found that Dataverse exposes a Web API action called.

Unlike creating a Status Reason through the UI, this API allows you to specify the exact integer value for the Status Reason.

Using the XrmToolBox Web API Launcher, we called the following endpoint:

As shown below, the request completed successfully.

What Happened Next?

Once the Status Reason was recreated with the same value (3) in the Development environment:

  • We exported the managed solution.
  • Imported it into UAT.
  • The deployment completed successfully.
  • No duplicate Status Reason values were created.
  • No new integer values were generated.
  • The existing Status Reason in UAT continued to work correctly.

Because both environments now contained the same Status Reason value, the managed solution imported without any issues.

 

Comment

This is a Required Field

Loading

Recent Updates

Blogs
25 Jun, 2026

Dynamics CRM Testing Checklist Before Production Deployment

There are certain things in a CRM project that a QA must validate or verify before any solutions gets deploy…

READ MORE
Blogs
19 Jun, 2026

How to Trigger a Power Automate Flow from Power Apps Code Apps (Latest Experience)

Building a Power Apps Code App is just the beginning. In real-world business applications, users often need to send emails,…

READ MORE
Blogs
31 Mar, 2026

Debugging Power Pages Server Logic Using Visual Studio Code

Power Pages Server Logic allows developers to execute secure backend JavaScript directly within Power Pages. It is commonly used for…

READ MORE