How to fix the error “Illegal Assignment from String to Decimal” while importing data from Sage to Salesforce

By | October 22, 2024

One common issue when integrating SF to any system is the “Illegal Assignment from String to Decimal” error, which occurs when string data from the other system is assigned to a numeric field in Salesforce. Integrating data between Salesforce and ERP (or any other system) can be complex, especially dealing with mismatched data types. This blog will explore why this error occurs and provide step-by-step solutions to handle it efficiently.

Understanding the Error: “Illegal Assignment from String to Decimal”

When integrating data from Sage into Salesforce, this error typically arises when a field in Salesforce is set to the number data type but the incoming data from Sage is formatted as a String. Salesforce will throw an error because it cannot automatically convert the string into a decimal or number.

Illegal Assignment from String to Decimal
Error in the logs

Why Does This Error Occur?

The root causes of the error “Illegal Assignment from String to Decimal” are often related to how data is structured and formatted between systems:

  • Sage sends data as a string: Sage may not enforce strict data type validation, which means numeric data could be formatted as a string.
  • Data formatting issues: The numeric values in Sage might include characters like commas, spaces, or currency symbols, making it difficult for Salesforce to interpret them as numbers.

Solutions to the Error “Illegal Assignment from String to Decimal”

Here are some strategies to resolve the issue “Illegal Assignment from String to Decimal” and ensure smooth integration between Salesforce and Sage:

Change Salesforce Field Type to String

The easiest solution to the error “Illegal Assignment from String to Decimal” is to change the data type of the problematic Salesforce field from Number to String. This allows Salesforce to accept the incoming data without conversion errors. Here’s how to update the field type:

Step-by-Step Guide:

  1. Navigate to Object Manager: In Salesforce Setup, search for “Object Manager.”
  2. Select the Object: Choose the relevant object (e.g., Sales Orders) where the field exists.
  3. Find the Field: Under “Fields & Relationships,” locate the field currently set to Number.
  4. Update the Field Type: Edit the field, changing its type from Number to Text (String).
  5. Save and Test: Save the changes and run your sync to check if the error is resolved.

Considerations Before Changing the Field Type

Changing a field’s type can have a ripple effect on related reports, workflows, and code that rely on that field being a Number. Be sure to update any dependent processes to handle the new data type correctly.

Another approach is to handle the transformation of string data to numeric format within the integration layer before it reaches Salesforce. You can implement logic that checks and converts strings to valid numbers.

Conclusion:
The “Illegal Assignment from String to Decimal” error is a common hurdle when integrating Salesforce with Sage. A straightforward solution is to change the Salesforce field type from Number to String, but this requires careful consideration of related systems and processes. Alternatively, you can handle data transformations in the integration layer to ensure data consistency.

By following the above blog instructions, you can streamline your integration and avoid this error, making your Salesforce-Sage integration smoother and more reliable. If you still have queries or any related problems, don’t hesitate to contact us at salesforce@greytrix.com. More details about our integration product are available on our website and Salesforce AppExchange.

We hope you may find this blog resourceful and helpful. However, if you still have concerns and need more help, please contact us at salesforce@greytrix.com

About Us
Greytrix – a globally recognized and one of the oldest Sage Development Partner and a Salesforce Product development partner offers a wide variety of integration products and services to the end users as well as to the Partners and Sage PSG across the globe. We offer Consultation, Configuration, Training and support services in out-of-the-box functionality as well as customizations to incorporate custom business rules and functionalities that require apex code incorporation into the Salesforce platform.

Greytrix has some unique solutions for Cloud CRM such as Salesforce Sage integration for Sage X3Sage 100 and Sage 300 (Sage Accpac). We also offer best-in-class Cloud CRM Salesforce customization and development services along with services such as Salesforce Data MigrationIntegrated App developmentCustom App development and Technical Support business partners and end users.
Salesforce Cloud CRM integration offered by Greytrix works with Lightning web components and supports standard opportunity workflow. Greytrix GUMU™ integration for Sage ERP – Salesforce is a 5-star rated app listed on Salesforce AppExchange.

The GUMU™ Cloud framework by Greytrix forms the backbone of cloud integrations that are managed in real-time for processing and execution of application programs at the click of a button.

For more information on our Salesforce products and services, contact us at salesforce@greytrix.com. We will be glad to assist you.

Related Posts