Applies to Product - Power Platform Administration
What’s happening?
When attempting to import data from an Excel file into Microsoft Dataverse, users encounter the following error message. This error prevents the import process from completing for affected records.
“The specified status code is not valid for the given state code.”
Reason:
The error occurs due to a mismatch in the default values of the status column between the production and pre-release environments. Specifically, the status code being used does not exist in the target environment's configuration.
Resolution:
To resolve this error, follow the appropriate steps below:
1. Verify Valid State–Status Combinations:
- Open the target Dataverse table in Power Apps.
- Navigate to Columns → statuscode.
- Check which statuscode values are allowed for each statecode (e.g., Active = 0, Inactive = 1).
- Ensure that each row in the import file only contains valid combinations.
If statecode = 1 (Inactive), but statuscode = 1 (Active), the record will be rejected unless that statuscode is allowed in the Inactive state.
2. Use Option Set Numeric Values Instead of Labels:
- Replace status and state labels in the Excel file (e.g., "Active", "Resolved") with their corresponding numeric values (e.g., 0, 1, 2).
3. Ensure Schema Compatibility Across Environments:
Scenario: File exported from a different Dataverse environment
Check if the Excel file was sourced from a different environment than the one you're importing into.
Use tools like:
- XrmToolBox → Metadata Browser
- Power Apps Solution Explorer
Resolution:
Update the import file to match the target environment’s schema (correct statecode and statuscode values).
Or, align the schemas by exporting/importing the same solution components (if feasible).
4. Optional: Use Dataflows or Power Automate for Schema-Aware Imports
If manual correction is not scalable, consider importing data using Power Platform Dataflows or Power Automate flows, which allow for data transformation and validation during import.
