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 code i have used only two fields (id, name), but in future we cannot expect these two fields are coming. Like we can get dynamically phone, email, DOB, State, country... etc fields from different objects to wrapper class. based on different object fields/ records/rows how can i update the wrapper class object Dynamically.
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;
}