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
:) :) :) :) :):) :) :) :) :) 

How to bind or concat String with 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()) {
for(String s : leadFieldsApiNames){
for(Lead TN :{
 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 for replying.

I want to bind or concat string variable (which is field API Name) with foreach temp ( foreach temp variable)  variable inside the foreach ( foreach). Please look and understand the above code you'll know what i am asking? 

All I can understand is that you are checking if a particular field value is changing. But not sure if that can be achieved with your code.

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.