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
StevenGreenStevenGreen 

Compile Error: Illegal assignment from List<Google_Config__mdt> to String at line 5 column 17

Hey All,

Learning coding/api at the moment so please bear with my stupidity.....i have an illegal assignment which i know means i am trying to put a square object through a circle hole.....can someone tell me what i am doing wrong?

Basically, i have a custom metadata type with a label of GoogleToken that i am trying to bring back.

User-added image
AbhinavAbhinav (Salesforce Developers) 
Hi,

Actually  you are assigning  a list of custom metadata to a String

Replace 
 
String query = [Select label From Google_Config_mdt WHERE Masterlabel ='GoogleToken'];

List<Google_Config_mdt>  g_CredList= Datebase.query(query);

with 
List<Google_Config_mdt>  g_CredList = [Select label From Google_Config_mdt WHERE Masterlabel =: 'GoogleToken' ];
If it helps mark it as best answer.

Thanks!
 
Suraj Tripathi 47Suraj Tripathi 47

Hi,

Please find the solution.

String query = 'Select label From Google_Config_mdt WHERE Masterlabel =\'GoogleToken\' ';
List<Google_Config_mdt>  g_CredList= Datebase.query(query);


or

List<Google_Config_mdt>  g_CredList = [Select label From Google_Config_mdt WHERE Masterlabel =: 'GoogleToken' ];

Please mark it as the Best Answer so that other people would take references from it.

Thank You

fsrtgfd grdhnffsrtgfd grdhnf
This is exactly the same issue that I am facing in my (https://thezalopc.com/) project I was thinking that I am doing something wrong but this guy also have a same probelm.