You need to sign in to do that
Don't have an account?
:) :) :) :) :)
How to bind or concat String with Trigger.new foreach statement.
I am trying to get all fields API name using getDescribe() and want to use them to bind with triggers foreach statement but couldn't figured out the way to do it. Please Help
Trigger myleadTrigger on lead(after update) {
Lead<String> leadFieldsApiNames = new Lead<String>();
Map<String, SobjectField> fieldMap = Lead.getsObjectType().getDescribe().Fields.getMap();
for(String f : fieldMap.keySet()) {
leadFieldsApiNames.add(fieldMap.get(f).getDescribe().getName()));
}
for(String s : leadFieldsApiNames){
for(Lead TN : Trigger.new){
for(Lead TO : Trigger.old){
if(TO.S != TN.S){
System.debug('Value has been chaged '+TN.S);
}
}
}
}
}
Trigger myleadTrigger on lead(after update) {
Lead<String> leadFieldsApiNames = new Lead<String>();
Map<String, SobjectField> fieldMap = Lead.getsObjectType().getDescribe().Fields.getMap();
for(String f : fieldMap.keySet()) {
leadFieldsApiNames.add(fieldMap.get(f).getDescribe().getName()));
}
for(String s : leadFieldsApiNames){
for(Lead TN : Trigger.new){
for(Lead TO : Trigger.old){
if(TO.S != TN.S){
System.debug('Value has been chaged '+TN.S);
}
}
}
}
}
Can you please explain more what you are trying to achieve with your code?
Thanks,
Shashank
I want to bind or concat string variable (which is field API Name) with foreach temp (Trigger.new foreach temp variable) variable inside the foreach (trigger.new foreach). Please look and understand the above code you'll know what i am asking?
TO.S != TN.S does not work. S is not a field on Lead object. Using a string which contais the value of the field name will not work.