I’m getting the below error while mapping a REST JSON payload to the clipboard: PropertyValueInvalid .pegaToBigDecimal() Invalid number format (was 1AB0)
In Pega, I’ve configured the corresponding property as Decimal.
I have below questions:
Has anyone encountered cases where JSON mapping tries to convert another field to Decimal and throws this error even though the issue appears related to surchargeAmount?
What is the recommended approach for amount fields that are defined as string in the API specification?
Hi, it looks like you are getting hexadecimal number in the payload and thats why you are getting a number format exception.
You might have to read the value as a string, then convert the hexadecimal value into a decimal value using a java function. Once you convert the string into a valid number format, you can set it to your decimal property.
Hello! I understand you’re experiencing a data type mismatch error when mapping a REST JSON payload to your Pega clipboard. Let me help you understand what’s happening and how to resolve it.
Understanding the Error:
The error “PropertyValueInvalid .pegaToBigDecimal() Invalid number format (was 1AB0)” indicates that Pega is attempting to convert a string value to a Decimal type, but the incoming value (“1AB0”) contains non-numeric characters that cannot be converted to a decimal number.
The Root Cause:
You’ve identified a key issue: in your Swagger specification, the surchargeAmount field is defined as a string type, but in Pega, you’ve configured the corresponding property as Decimal. This type mismatch is causing the conversion error when the JSON data contains values that aren’t valid decimal numbers.
Recommended Approach:
Based on Pega best practices for handling amount fields:
Match the Data Types: When mapping JSON properties to Pega properties, it’s important that the data types align properly. If your API specification defines the field as a string, you have two options:
Option A: Change your Pega property to Text type to match the API specification. This will accept any string value without conversion errors.
Option B: If you need to perform calculations on this amount, keep it as Decimal in Pega, but implement validation and data transformation logic to handle non-numeric values gracefully before the mapping occurs.
Handle Data Type Discrepancies: Similar issues have been documented in Pega applications. For example, in the Pega Common Application, there was a known issue where the Transaction.Amount property was defined as Decimal in the class but the database column was varchar. This discrepancy resulted in system errors. To resolve it, Pega created a new TransactionAmount property with the correct data type alignment.
Consider Using Currency Type: If this field represents monetary amounts, you might want to use the Currency field type instead of Decimal. The Currency type is specifically designed for handling currency codes and values with proper localization support.
Implement Data Validation: Before mapping, consider adding validation logic to check if the incoming string value is a valid numeric format. You can use data transforms to clean or validate the data before it reaches your Decimal property.
Addressing Your Specific Questions:
Can mapping try to convert another field? Yes, if you have multiple fields with similar type mismatches in your JSON mapping, any of them could trigger this error. Review all your property mappings to ensure data types are consistent between the JSON payload and your Pega properties.
Best practice for string-defined amount fields: The recommended approach is to either match the string type in Pega or implement a data transformation layer that validates and converts the string to a proper decimal format before mapping. This gives you control over how invalid values are handled.
I hope this helps you resolve the issue! If you need to perform arithmetic operations on these amounts, I’d recommend implementing proper data validation and transformation logic to ensure only valid numeric strings are converted to Decimal types.