Hi I have a package that migrates data from Salesforce into Dynamics. One of the fields mapped is of type string at source, and it's target is a Decimal. I would like to have a catch and set default value in the case that the typecast fails. Is there a way how this can be done? As it stands the whole record import will fail when a typecast failure happens. Here is my expression. isnullorempty(StorageSqMetresc ) ? 0 : decimal(StorageSq_Metresc)
String to Decimal Typecast Catch Error
- 275Views
- Last Post 04 November 2022
Hello Brendan.
Thank you for contacting us.
You can try Expression mapping feature for this purpose. Please check this link and let us know whether it helps https://docs.skyvia.com/data-integration/common-package-features/mapping/expression-mapping.html
If you need any additional information please let us know and share the Package Id which you need to add the expression in.
We are looking forward to hearing from you.
Beat regards,
Yevheniia Bilotserkovska.
Thanks for your reply. I am using the expression feature. See my expression below.
The problem is that if decimal() typecast fails, there is no catch to set a default value and as a result the whole record won't be imported.
Hello Brendan.
Thank you for your reply.
Could you please share the Package ID you have issue with?
Hello Brendan.
Thank you for your reply.
Please note that, unfortunately, it is not possible to specify the condition to skip entries in the expression if errors are returned. It is normal behavior that if decimal() typecast fails then the whole record won't be imported.
As we can see from your error log you have got an 'Error evaluating 'ergo_storagesqm' from expression 'is_null_or_empty(Storage_Sq_Metres__c ) ? 0 : decimal(Storage_Sq_Metres__c)': Cannot convert 'string' to 'decimal'.'
It means that you need to check values of the field Storage_Sq_Metres__c - looks like it contains letters which does not allow converting the data into the decimal format.
Could you please check and let us know whether it helps.