Loading
Salesforce now sends email only from verified domains. Read More

Email fails with the error Failed to convert parameter value from a String to a Int32

Publish Date: Oct 13, 2022
Description

AMPScript can be used in email content to compare variables or use variables in various functions. If the data types are not consistent or the value used for a function is NULL, the email can fail with the error below:

System.FormatException: Failed to convert parameter value from a String to a Int32. - from System.Data -->
Resolution

To resolve the error, validate that all data types used in the comparison are consistent. If you are certain that the values being leveraged within the AMPScript are the correct and matching data types, it is possible that you are passing a NULL value within your function. 

As an example of the mismatched data type scenario, say you have a Lookup function that compares a variable to an integer data type within a Data Extension:
Lookup("TestLookup","SubscriberKey","LookupFieldNumber",@numberValue)

If you pass a string value in the @numberValue variable, this will fail with the error listed above.

As an example for the NULL value scenario, say you have the same Lookup function that compares a variable to an integer data type within a Data Extension:
Lookup("TestLookup","SubscriberKey","LookupFieldNumber",@numberValue)

If you have passed a NULL value into the @numberValue variable looking up a match to an Integer data type, this will fail with the data type conversion error as well. 

Text fields should be compared to other text fields and integers should be compared to integers.

Knowledge Article Number

000382842

 
Loading
Salesforce Help | Article