I am developing an apex code to scan an email and use some values i can found. I have a custom object used to map the labels to existing fields.
Then i have a map with field names and values. I would like to create and value an object (Lead) with this map.
Of course i don't want to list every field of the object.
I could do something like :
private void add(String field, String value){
if(field==null || value==null) return;
try{
test.put(field, value);
}
catch(Exception e){}
try{
test.put(field, Date.parse(value));
}
catch(Exception e){}
try{
test.put(field, DateTime.parse(value));
}
catch(Exception e){}
try{
test.put(field, Integer.valueOf(value));
}
catch(Exception e){}
}
Is there a cleaner way to do it ?
Thanks !