Problem
When attempting to save or validate a basket in the Solution Console, the operation fails with a validation error for a required attribute that has been set to zero (0). The error typically appears as:
Contract Term is required
or similar validation messages, even though the attribute has been populated with a value of 0.
This prevents basket save, validation, and order generation operations from completing.
Root Cause
The issue occurs when a required attribute is configured with an incorrect data type (typically "String" instead of "Integer" or "Decimal") in the Attribute Definition.
In JavaScript and Salesforce validation logic, the numerical value 0 is considered a "falsy" value. When an attribute is:
1. Marked as required in the Attribute Definition
2. Configured with data type String
3. Populated with the value 0
The validation logic treats 0 as equivalent to an empty or null value, causing the required field validation to fail.
Resolution Steps
Option 1: Change Attribute Type to Integer or Decimal (Recommended)
- Navigate to Attribute Definition Setup:
- Go to Setup > Custom Settings > Attribute Definitions
- Search for the affected attribute (e.g., "Contract Term")
-
Open the Attribute Definition record
-
Update the Data Type:
- Locate the "Type" field on the Attribute Definition
- Change the value from "String" to:
- Integer (if the attribute should only store whole numbers)
- Decimal (if the attribute may store decimal values)
-
Save the Attribute Definition
-
Verify the Change in Solution Console:
- Open the affected basket in the Solution Console
- Open the browser console and run the following command to verify the attribute type:
javascript await CS.SM.getActiveSolution().then(s => s.schema.configurations["<CONFIGURATION_GUID>"].attributes["<ATTRIBUTE_NAME>"] )
-
Check that the
typeproperty now shows "Integer" or "Decimal" -
Retry Save/Validation:
- In the Solution Console, click "Save" or "Validate"
- The operation should now complete successfully without the validation error
Option 2: Remove the Required Flag
If the attribute should allow zero or empty values:
- Navigate to Attribute Definition Setup:
- Go to Setup > Custom Settings > Attribute Definitions
-
Open the affected Attribute Definition record
-
Update the Required Flag:
- Uncheck the "Required" checkbox
-
Save the Attribute Definition
-
Retry Save/Validation:
- The validation error should no longer appear when the value is 0
Verification
To verify the attribute configuration in the Solution Console:
await CS.SM.getActiveSolution().then(s =>
s.schema.configurations["<CONFIGURATION_GUID>"].attributes["<ATTRIBUTE_NAME>"]
)
Expected output for a correctly configured integer attribute:
{
"name": "Contract Term",
"type": "Integer",
"required": true,
...
}
Prevention
To prevent this issue when creating new attributes:
- Use Integer or Decimal data types for numeric attributes that may have a value of 0
- Reserve the String data type for text-based attributes only
- When migrating or cloning Attribute Definitions, verify that numeric attributes are not inadvertently set to String type
- Test validation with edge cases (0, negative numbers, decimals) before deploying to production
Important Notes
- This issue can affect any required attribute that uses String type and may have a value of 0
- Changing the attribute type does not require deploying a new Solution Definition version
- If the attribute is used in multiple Solution Definitions, verify and update each one
- Compare the configuration of the problematic attribute with other working numeric attributes in your system to identify discrepancies
Priyanka Bhotika
Comments