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
JaanuJaanu 

illegal conversion from List to String ?

    public static String getId(String Id){
        return [SELECT HCP_Affiliation__c.Id FROM HCP_Affiliation__c WHERE HCP_Affiliation__c.Patient__c =:Id LIMIT 1];
   
I am getting error msg with the above statement saying "illegal conversion from List to String " ... I am limiting to one record ..not sure what the issue is.
Pascal Le ClechPascal Le Clech
Seriously ?

solution :
HCP_Affiliation__c record = [SELECT HCP_Affiliation__c.Id FROM HCP_Affiliation__c WHERE HCP_Affiliation__c.Patient__c =:Id LIMIT 1];
return record.HCP_Affiliation__c.Id;

but what if there is no result ?
You should code a bit more securely.