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
Develper RKrishDevelper RKrish 

Explaination needed on FOR loop.

This code is to check duplicate records.

 

i want the functionality of this.

 

for(Fasttrack_Activity__c FA : Trigger.new)

      {

              if(FA.Name == 'photo')

              {

                      FA.Name.addError('Duplicate Name');

              }

      }

digamber.prasaddigamber.prasad

Hi,

 

This FOR loop will retrieve each record one by one. It will check if "NAME" of Fasttrack_Activity__c record (new or updated value) is 'Photo' it will add error on that record saying 'Duplicate Name'.

 

Let me know if you have any specific question.

 

Happy to help you!

AshishyadavAshishyadav
For loop ( your_object_Name refname : Trigger.new)

In this particular code whenever new record is created on object Fasttrack_activity__c ,, this particular condition is checked which is inside for loop

Trigger.new will create number of newly created record , suppose you insert the data by dataloader in bulk let say 10 records, so its like
for i=1 ; i<= 10 ; i++

first loop step: FA[1] will contain first record
second looping; FA[2] will contain second record

I hope you got it