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
Carolyn juliana 7Carolyn juliana 7 

How to fix Illegal conversion to List

Hi,
I am getting this error for this code ,how do i fix it
 
public with sharing class saveCaseType {
     
     @AuraEnabled
     Public  static List<String>  savecasetype(string level1,string level2,string level3,string caseid){
     ERT_Case_Type__c obj=new ERT_Case_Type__c();
     Obj.Id =caseid;
     Obj.Level_1__c=level1;
     Obj.Level_2__c=level2;
     Obj.Level_3__c=level3;
     Insert obj;
     return obj;
     }
    
    
    

}

 
Best Answer chosen by Carolyn juliana 7
Andrew GAndrew G
your code has stated that the method will return a List
Public  static List<String>  savecasetype(string level1,string level2,string level3,string caseid){
but your code is returning a single object / record.
return obj;

you either need to change the declaration to something like:
Public  static Case_Type__c savecasetype(string level1,string level2,string level3,string caseid){
or create a list of Strings to be returned by the method


regards
Andrew