function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
kevinjia1984kevinjia1984 

A Question about data type

Hi all,

Can I make an text data type equals to a string value in the syntax like object1.textField =(text)object1.stringField? If not, how can i get it. Many thanks for any help.

Best Answer chosen by Admin (Salesforce Developers) 
Pradeep_NavatarPradeep_Navatar

The Text data type takes number as well as string values so no need to convert string value in text. If you need then there is methods for the conversion of the data types-

 

                Boolean b = s.equals('TRUE');

 

                String s = '19';

                a.NumberOfEmployees = Double.valueOf(s);

 

                Date myDate = Date.Today();

                String sDate = String.valueOf(myDate);

 

                Double myDouble = 12.34;

                String myString = String.valueOf(myDouble);

 

All Answers

goabhigogoabhigo

What you mean by 'object1.stringField'? 

When you create new custom field there is only 'Text' data type which stores alphanumeric characters(also strings).

Pradeep_NavatarPradeep_Navatar

The Text data type takes number as well as string values so no need to convert string value in text. If you need then there is methods for the conversion of the data types-

 

                Boolean b = s.equals('TRUE');

 

                String s = '19';

                a.NumberOfEmployees = Double.valueOf(s);

 

                Date myDate = Date.Today();

                String sDate = String.valueOf(myDate);

 

                Double myDouble = 12.34;

                String myString = String.valueOf(myDouble);

 

This was selected as the best answer
kevinjia1984kevinjia1984

Thanks a lot