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
QCmduffQCmduff 

Trigger Compile Error

I am declaring a String variable = to an existing Case field of Text data type in a Trigger. Why am I getting this Compile Error? 

 

"Illegal assignment from Schema.SObjectField to String"

JonPJonP

Post your code.  You are probably referring to the Field on the abstract Schema Object:

 

 

String s = Account.Name;

 

...rather than to the value of a field on an instance of the object:

 

 

Account a = [SELECT Name FROM Account WHERE Name = 'Foo' LIMIT 1]; String s = a.Name;

 

 

 

 

nicloznicloz

Yes, I have the same error I have this code

 

Account a = [SELECT Name FROM Account WHERE Name = 'Foo' LIMIT 1];
String s = a.Name;// I can save it, but when I run the application I get another error.
String c = Account.Name;//second option I get the below error.


 

 

With the second option I got the error " Illegal assignment from Schema.SObjectField to String"...

 

Please help me.