본문 바로가기

개발

System.TypeException: Invalid conversion from runtime type String to Integer

728x90
String str = '123';
Integer int = (Integer) str;

원인

String 타입을 아래와 같이 cast하려고하여 이슈 발생

 

String str = '123';
Integer int = Integer.ValueOf(str);

 

수정

Decimal, Double등의 타입으로는 가능하나 compatible하지 않은 String의 경우 아래와 같이 수정하여 사용해야 한다

 

 

출처 : https://developer.salesforce.com/forums/?id=906F00000008yxFIAQ

 

728x90