Skip to content
+1-888-319-3663

COMMUNITY FORUM

conversion from string " " to type 'Double' is not valid

Deanne rasmussen asked 5 years ago
If (_MONTHLYIMPRESSIONSCALCULATED <> ” “) Then
            Return _PRODUCTNAME & ” – “ & _MONTHLYIMPRESSIONSCALCULATED
        Else
            Return _PRODUCTNAME
 
        End If
Here’s our formula – any suggestions?  We get Error in ‘MsGpDestination’.  Line ‘taSopLineIvcInsert___E55F45DF-CA20-4FA4-865B-A5D401054F6C’
Parameter ‘Item description’
Parameter set value event.
 
 
Answers
Brady Swenson answered 5 years ago
 
The message “conversion from string ” ” to type ‘Double’ is not valid” is likely a result of comparing two values that are not related.
 
In your example, it is likely the calculated field “MONTHLYIMPRESSIONSCALCULATED” and the fact you are comparing it to a string value. 
 
You can use the ToString function to convert the calculated field in both your If statement and the return statement, which should resolve your issue.
 
 
 
If (_MONTHLYIMPRESSIONSCALCULATED.ToString <> ” “) Then
            Return _PRODUCTNAME & ” – “ & _MONTHLYIMPRESSIONSCALCULATED.ToString
        Else
            Return _PRODUCTNAME
 
        End If
 
Tanya Henderson answered 3 years ago
I am getting this same error and I am trying to do a calculated field for a dollar amount.
if _REN_FEESCHEDULE_REN_FEETYPE = “Deposit” then
return _REN_TOTALPRICE*.35
else
return _REN_TOTALPRICE
end if
I have tried ToString on multiple places, but get the same error.
Help and thank you.
Tanya
Lorren Zemke replied 3 years ago

Tanya, the reason ToString() doesn’t work for you is because your source column is already considered a string. You have to convert it to a number so you can do maths on it.

return Double.parse(_REN_TOTALPRICE) * .35

or

return Decimal.parse(_REN_TOTALPRICE) * .35

both statements will give you the same result.


If you would like to submit an answer or comment, please sign in to the eOne portal.