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
Vijay@sfdcVijay@sfdc 

looping issue ,

Hello Everyone,

advance Thanks,  i have issue with bellow iteration in code, could any help to fix the below code snippet

for(Ientry__c ie:Entry)
        {
            integer i=0;
            system.debug('ingeger==>>> '+i);
            ie.Incentive_Actual__c=Incentiveactual[i].id;
            if( i==1) ie.Appointmenttype__c='appointment';
                else
                if(i==2) ie.Appointmenype__c='sale';
                else
                if(i==3)ie.Appointmenttype__c='status';
                else
            ie.Appointment_incentive_type__c='lead';
    
            i=i+1;
        }
in the above code i value is not increasing , its being always "ZERO",

can any one help me to fix the above code
Best Answer chosen by Vijay@sfdc
Amit Chaudhary 8Amit Chaudhary 8
Update your code like below


integer i=0;
for(Ientry__c ie:Entry)
        {
            system.debug('ingeger==>>> '+i);
            ie.Incentive_Actual__c=Incentiveactual[i].id;
            if( i==1) ie.Appointmenttype__c='appointment';
                else
                if(i==2) ie.Appointmenype__c='sale';
                else
                if(i==3)ie.Appointmenttype__c='status';
                else
            ie.Appointment_incentive_type__c='lead';
    
            i=i+1;
        }

Let us know if this will help you

Thanks
Amit Chaudhary

All Answers

Amit Chaudhary 8Amit Chaudhary 8
Update your code like below


integer i=0;
for(Ientry__c ie:Entry)
        {
            system.debug('ingeger==>>> '+i);
            ie.Incentive_Actual__c=Incentiveactual[i].id;
            if( i==1) ie.Appointmenttype__c='appointment';
                else
                if(i==2) ie.Appointmenype__c='sale';
                else
                if(i==3)ie.Appointmenttype__c='status';
                else
            ie.Appointment_incentive_type__c='lead';
    
            i=i+1;
        }

Let us know if this will help you

Thanks
Amit Chaudhary
This was selected as the best answer
Vijay@sfdcVijay@sfdc
Thnaks for replay Amit :)