Hi to Salesforce ,
Here is the small snippet that can help to identify which field is changed on the record using sobject methods.
Here is the small snippet that can help to identify which field is changed on the record using sobject methods.
list<string> lstAPIfields = new list<string>();
Map <String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
Map <String, Schema.SObjectField> fieldMap = schemaMap.get('Lead'). getDescribe().fields.getMap();
for(Schema.SObjectField sfield : fieldMap.Values()){
schema.describefieldresult dfield = sfield.getDescribe();
if(dfield.isUpdateable()){
lstAPIfields.add(dfield. getname());
}
}
system.debug('**** lstAPIfields'+lstAPIfields);
for(lead objlead:lstNew){
sobject sobjNew = objlead;
sobject sobjOld = mpOld.get(objlead.id);
for(string strfield:lstAPIfields){
if(sobjNew.get(strfield)!= sobjOld.get(strfield)){
system.debug('***********FIELD MODIFIED'+strfield);
}
}
}
Thank you.
ReplyDeleteAwesome article. It is so detailed and well formatted that i enjoyed reading it as well as get some new information too.
Salesforce training in Chennai