You need to sign in to do that
Don't have an account?
HAZLITT VASUDEVAN
Static method cannot be referenced from a non static context: String String.valueOf(Object)
public class sand {
public static void force()
{
Work_Order__c work = new Work_Order__c();
work.Name = 'Asian Paints';
work.WO_Number__c = 1547586597;
work.Account_Id__c = 12345678;
work.Email_Body__c = ' ';
String a = work.Email_Body__c;
String[] arr = new List<String>();
arr.add('Hello.');
arr.add('Welcome to salesforce,');
arr.add('Name');
arr.add('Asian Paints');
arr.add('WO Number');
arr.add('1547586597');
arr.add('Account Id');
arr.add('12345678');
for(integer i=0; i<arr.size(); i++)
{
System.debug(arr[i].valueOf(work.Email_Body__c));
}
insert work;
System.debug(work);
}
}
public static void force()
{
Work_Order__c work = new Work_Order__c();
work.Name = 'Asian Paints';
work.WO_Number__c = 1547586597;
work.Account_Id__c = 12345678;
work.Email_Body__c = ' ';
String a = work.Email_Body__c;
String[] arr = new List<String>();
arr.add('Hello.');
arr.add('Welcome to salesforce,');
arr.add('Name');
arr.add('Asian Paints');
arr.add('WO Number');
arr.add('1547586597');
arr.add('Account Id');
arr.add('12345678');
for(integer i=0; i<arr.size(); i++)
{
System.debug(arr[i].valueOf(work.Email_Body__c));
}
insert work;
System.debug(work);
}
}
The error is in line system.debug statement, the valueOf string method declartion is wrong.
it should be like this May I know the purpose of for loop and system.debug statement?
Are you trying to convert work.Email_Body__c to string?
Thanks
Surya G
can you please tell what your trying to convert by valueOf, after that i will able to suggest for better approach.
Regards
Mukesh
Hi Hazlitt,
your arr does not contain a value for work.Email_Body__c
so you can print array values like this
All the values are string inside arr so need to convert.
ValueOf()=> this function use to convert data from one to another
example
Please mark it as the Best Answer
use:
String a = work.Email_Body__c;
arr.add(a);
for(integer i=0; i<arr.size(); i++) {
if(arr[i]==a){
System.debug(arr[i]);
}
}