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....
user avatar
  • 3,976
15 votes
Accepted

Nested aura:iteration to dynamically get fields

As far as I can tell, Lightning components don't support that dynamic reference syntax. You could consider dynamically generating the content of this component with the component controller: ...
user avatar
  • 12.2k
15 votes
Accepted

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

You're absolutely correct. The system basically gathers everything upfront. This allows the system to display the total number of batches before it starts processing the data. The "why" has to do ...
user avatar
  • 429k
12 votes
Accepted

Stop Batch Process

I've never tried it, but I don't see anything in the System.abortJob documentation that says it doesn't work when called from the batchable so try: public void execute(Database.BatchableContext bc, ...
user avatar
  • 129k
9 votes
Accepted

Lightning Aura Iteration ReRender

Great question! You need to AuraEnable the properties in the wrapper class.
user avatar
  • 1,503
8 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 ...
user avatar
  • 2,731
7 votes

Number of iterations exceeded - Flow Error

I have also been running into the 'Number of iterations exceeded' limit. It seems to be the 'Maximum number of executed elements at runtime' limit that I am hitting (the limit is 2000, see the ...
user avatar
  • 71
7 votes
Accepted

Why is my Lightning aura:iterate component not iterating?

Please change <aura:attribute name="expenses" type="Sledgehammer.Expense__c" /> to <aura:attribute name="expenses" type="Sledgehammer.Expense__c[]" /> in your "form.cmp"
user avatar
  • 1,534
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()....
user avatar
6 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 ...
user avatar
  • 10.6k
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">
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 ...
user avatar
  • 429k
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: ({ ...
user avatar
  • 1,004
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>(...
user avatar
5 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 ...
user avatar
5 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 - ...
user avatar
  • 33.5k
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). ...
user avatar
  • 811
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"> <...
user avatar
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 ...
user avatar
  • 10.1k
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 ...
user avatar
  • 589
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 ...
user avatar
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 ...
user avatar
  • 142k
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 ...
user avatar
  • 142k
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; ...
user avatar
  • 9,063
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 ...
user avatar
  • 4,654
3 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 ...
user avatar
3 votes
Accepted

How to get Map collection out of a list?

If it's just a contains check, then an additional, set holding all the ProductId values would be the simplest approach to avoiding the iteration over the AccountId values and would probably make the ...
user avatar
  • 129k
3 votes

How to use <force:inputField> and <force:outputField> inside an <aura:iteration>

It's about 2 years after I initially touched this issue and today I've found this Known Issue here https://success.salesforce.com/issues_view?id=a1p3A0000008gDzQAI It confirms my ancient ...
user avatar
  • 33.5k
3 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 ...
user avatar
  • 429k
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 ...
user avatar
  • 429k

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