Skip to main content
17 votes
Accepted

How to implement on scroll action in lightning to show next few list of records

You could implement infinite scrolling similar to what I did for my custom Lightning Component that renders data table. In your main component's render.js file attach a listener to the window....
Doug Ayers's user avatar
  • 4,186
9 votes
Accepted

Lightning Aura Iteration ReRender

Great question! You need to AuraEnable the properties in the wrapper class.
JRiffe's user avatar
  • 1,653
9 votes
Accepted

LWC: detect last element in for:each iteration

Just as addition to gNerbs answer: if you really need or want a own component you can use the iterator directive which has a first / last item attribute Like: <template> <template ...
Renji-xD's user avatar
  • 2,791
7 votes

How to iterate a Map in Aura

Pretty much all browsers support the JavaScript method Object.keys() which takes in an object and returns an array of just its keys. So you could have a second attribute of type String[] and set it in ...
Charles T's user avatar
  • 11k
6 votes
Accepted

Using next method in iterator

As you have mentioned you have only one element, that is why you are facing this problem. you are using; system.debug('skill is----------------->>>>>>' + iter.next().Name ); js.Skill__c=iter.next()....
Saumya Ranjan Satapathy's user avatar
6 votes
Accepted

How Custom Iterators with Iterable Work

The overall answer to this is that there is an Apex Batch Handler which controls batch class execution. You could think of it like a method that calls your start method, then launches threads which ...
IllusiveBrian's user avatar
6 votes
Accepted

Lightning Components: How to do nested aura:iteration of a list of Accounts with subselected Contacts?

in your second iteration, use {!account.Contacts} instead of {!v.account.Contacts} <aura:iteration items="{!account.Contacts}" var="contact">
Jason Benkert's user avatar
5 votes

Why aren't iterators in batch jobs lazy-loaded?

With the introduction of chaining Queueable, and the ability to chain Queueable with callouts, we can daisy-chain multiple callouts efficiently without having to "guess" how many batches we need ...
sfdcfox's user avatar
  • 491k
5 votes
Accepted

Aura:Iteration Tag Not Working

You need to call the DoInit handler. Rename your javascript from "getMyObjects" to "doInit." Component: <aura:handler name="init" value="{!this}" action="{!c.doInit}"/> Controller: ({ ...
jmdohn's user avatar
  • 1,064
5 votes
Accepted

Looping Through A Map

So, this snippet should do it. (I am being more verbose than I need to, for clarity's sake) List<User> usersWithDupes = <your list here> Set<User> usersUnique = new Set<User>(...
Sebastian Kessel's user avatar
5 votes

Expressions in for:each index value in LWC?

Solution 1 - Use plain old html If you want to render a list in numerical order, starting at any number of your choice, you could use <ol> (ordered list) instead of <ul> (unordered list). ...
akiradev's user avatar
  • 851
4 votes

Looping Through A Map

So you have a collection of users and you want to remove any with duplicate names? You could do that when building the first map using Map<string, Map<string, User>> where the inner string ...
Daniel Ballinger's user avatar
4 votes

Aura :iteration and :if, WARNING: Performance degradation..

It turns out that using an :if in an :iteration is not recommended. From the salesforce developer documentation: Here are some use cases where you should consider alternatives to <aura:if>: You ...
nicstella's user avatar
  • 589
4 votes
Accepted

Lightning Component - data binding not working on sObject [] for new element pushed in array

I was able to reproduce the issue with locker service enabled.Looks like a bug in LC. As a workaround, you could create new instance of the array and set it to alltests aura:attribute. So replace ...
Praveen's user avatar
  • 10.1k
4 votes

Is there a Salesforce solution to Filter or Limit Aura iteration?

Just for reference, here is verified working code - it's very similar to that shown above, but I fixed a couple of issues: <aura:iteration items="{!v.objWrap}" var="item" indexVar="idx"> <...
Caspar Harmer's user avatar
4 votes
Accepted

Copy a list to another list

If you look into documentation You can use list.clone() Example List<Skill_Review__c> results = [SELECT Id,Name,Skill__c,Level__c FROM Skill_Review__c ...
Ratan Paul's user avatar
  • 22.7k
4 votes
Accepted

Adding/removing elements from a `Map` while iterating over it

In addition to my previous answer here, the documentation says that you should not remove elements of a current collection: To remove elements while iterating a list, create a new list, then copy ...
sfdcfox's user avatar
  • 491k
4 votes
Accepted

Inserting Records using a lightning component

A conceptual approach could be store the data you need as custom data-attributes in the <li> collect the data you need into a JavaScript object (I use jquery for DOM-operations like this - ...
Uwe Heim's user avatar
  • 28.4k
4 votes

how to use wrapper class in batch iterator (using custom iterator)?

Note that there are two separate classes: Iterable and Iterator. In your question you use the latter where the interface demands the former. Note also that a List is an Iterable: Object demo = new ...
Adrian Larson's user avatar
  • 150k
4 votes
Accepted

Exception not being caught; System.FinalException: Cannot modify a collection while it is being iterated

Your exception is not being caught because FinalException is not catchable. Neither are LimitException nor AssertException. You can quickly check for yourself if a given type of exception is ...
Adrian Larson's user avatar
  • 150k
4 votes

LWC: detect last element in for:each iteration

Build your string in Javascript and just display it to the page as opposed to using the for:each template. @track animalString; @wire(getAnimals) assignAnimals(animals) { this.animals = animals; ...
gNerb's user avatar
  • 9,491
4 votes
Accepted

Get all the Ids that were inserted by Database.insert - without iterating each record

There is no way to do this without an iteration, as the only viable alternative, using a Map, won't work with one or more null values present in the list. You don't need to check success first: Set<...
sfdcfox's user avatar
  • 491k
4 votes
Accepted

How to access an list from a list which stores all the list names

This is where you should use a Map. By having a key, you can then dynamically retrieve the values i.e find me the list values of map entry called lstStrng. Here is a broken down version of adding two ...
TSmith's user avatar
  • 5,002
4 votes
Accepted

Why can a Set be modified in an Apex loop but not a List?

In Iterating Collections, we are instructed: Collections can consist of lists, sets, or maps. Modifying a collection's elements while iterating through that collection is not supported and causes an ...
sfdcfox's user avatar
  • 491k
3 votes

iterating a multidimensional List

Yes, you're going to need two loops. That's the price you pay for having to parse a two-dimensional list. The trick is to put the record you're creating outside the inner loop. However, since you also ...
sfdcfox's user avatar
  • 491k
3 votes
Accepted

List iteration - item with space

Store them in their own list of strings and then iterate over the list and you should achieve the result you're looking for <aura:attribute name="vehicles" type="String[]" default="['boat','car','...
SFDC Noob's user avatar
  • 378
3 votes
Accepted

Iterate related records, display images from string name of contentAsset in Community Cloud

You're on the right track, just missing some pieces to keep moving forward. You'll want to reference an apex controller which helps you with server side actions and surfaces the results to your ...
Stas Christiansen's user avatar
3 votes

Expressions in for:each index value in LWC?

@akiradev provided two viable solutions... Here's a third. You can loop through your array of contacts and assign them a new property: this.contacts.forEach((contact, idx) =>{ contact.number ...
Matthew Souther's user avatar
3 votes
Accepted

LWC: Can a "<template for:each=" be used with an inner "<template for:each=" where the inner for-each gets its value using the key from the outer?

This is not possible in Aura or LWC, actually. for:each must have an Array to work off of. That means you must structure your data such that: <template for:each={transactions} for:item="...
sfdcfox's user avatar
  • 491k
3 votes
Accepted

LWC: Refresh for:each loops when new Array item added

Should this update automatically? I've imported "track" from LWC however I don't @track periods as @track'ing attributes are no longer required. It's no longer necessary for simple objects. ...
sfdcfox's user avatar
  • 491k

Only top scored, non community-wiki answers of a minimum length are eligible