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
Rajasekhar TRajasekhar T 

How to update wrapper class dynamically based on Different objects records/Fields?

I have written the following WrapperClass, consisting different object records/rows/fields as members. How can I dynamically update this wrapper class object. in below coade i have used only two fields (id, name), but in future we cannt expect thse two fields are coming. Like we can get phone, email, DOB, State, country... etc fields to wrapper class. based on different object fields/ records/rows how can i update the wrapper class object
set<string> ids= new set<string>();
        List<fieldWrapper> datalist1 = (List<fieldWrapper>) JSON.deserialize(Datalist,List<fieldWrapper>.class);
        
        for(fieldWrapper wrapper: datalist1)
        {
            If(Filedvalue =='id'){
            ids.add(wrapper.id);
            }
            If(Filedvalue =='Name')
            {
               ids.add(wrapper.Name);
            }            
        }
        If(Filedvalue =='id'){
              query+=':ids';
            }
            If(Filedvalue =='Name')
            {
              query+=':ids';
            
         } 
         
        
        List<sObject> sobjList = Database.query(query);
        return sobjList;
    
    public class fieldWrapper
    {
        public string id;
        public string Name;
    }