• Mohan Babu Kutuvan Janakiraman
  • NEWBIE
  • 10 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 3
    Replies
Hello All,

I'm new to Salesforce Apex coding and undergoing some training and classes in Apex. I noticed that we cannot give any condition in List FOR loop. For example, lets say I've a list of 1000 Contacts in myContactList. I need to loop myContactList for one particular account instead of running all the records one by one and check inside the loop if the account name is what am expecting. I've seen we can use SOQL for this. But my question is can we not use the local list variable to have filter and loop only the records which I want to?

Something similar to below code for reference:
for (Contacts myContact : myContactList.Where(Account.Name = 'Acme')){

}

Let me know if there are any way I can achieve this using myContactList instead of having SOQL call.

Thanks.

Regards,
Mohan Babu
I am in Admin - Beginner > Data Modeling > Create Custom Objects and Fields. 

Up until this point, I was able to correct challenges and validate them.  Now, I cannot get Trailheads to ackloedge the launch of the Developer Edition.  I have double and triple checked my work.  

I tried again in "Admin - Beginner > Data Modeling > Create Object Relationships" and I get the same response.
In previous challenges, it recognized that I actually launched the Developer Edition so I assume that's part of the program.

I was using Chrome, but moved to IE.  I also cleared history/cache in IE as well.

I don't want to move on without confirming my work.  And to not know which ones I have already completed.

Here is a screenshot as well: .. Should it recognize the Developer Edition is launched?

User-added image
 
Hello All,

I'm new to Salesforce Apex coding and undergoing some training and classes in Apex. I noticed that we cannot give any condition in List FOR loop. For example, lets say I've a list of 1000 Contacts in myContactList. I need to loop myContactList for one particular account instead of running all the records one by one and check inside the loop if the account name is what am expecting. I've seen we can use SOQL for this. But my question is can we not use the local list variable to have filter and loop only the records which I want to?

Something similar to below code for reference:
for (Contacts myContact : myContactList.Where(Account.Name = 'Acme')){

}

Let me know if there are any way I can achieve this using myContactList instead of having SOQL call.

Thanks.

Regards,
Mohan Babu