Questions tagged [iteration]
The iteration tag has no usage guidance.
110
questions
11
votes
2
answers
13k
views
How to iterate a Map in Aura
I have a aura map attribute defined in my component file as below
<aura:attribute name="FilesNameMap" type="Map">
But i am not able to understand how to iterate this in the component file as ...
11
votes
1
answer
775
views
Comparing Apex Loops and why Iterators are dramatically slower than for loops?
I decided to use iterators to work with collections in a functional style at some point in development, but immediately noticed a CPU time performance drawdown. So I decided to do a simple performance ...
9
votes
2
answers
1k
views
Why aren't iterators in batch jobs lazy-loaded?
I have a batch job that needs to callout to an external web service and retrieve a variable number of records. Seems like a perfect use-case to have an iterator which performs the callouts until there ...
9
votes
1
answer
16k
views
Nested aura:iteration to dynamically get fields
I am trying to dynamically create a data table with two arrays (SObject array and a String array which has field API name).
The two arrays are Contact[] and String[], where String[] consists of ["Id",...
9
votes
1
answer
7k
views
Stop Batch Process
Good day everyone,
I have created a batch process. Let say I have thousands of records to process. Now what i want is when there is an error encounter or some problem found in the data during the ...
8
votes
1
answer
9k
views
How to implement on scroll action in lightning to show next few list of records
I want to render many(about 1000) components and I am displaying them through aura:iteration in another aura:iteration. This is causing me performance issues. I want to display only 10 records at an ...
8
votes
4
answers
8k
views
How to use <force:inputField> and <force:outputField> inside an <aura:iteration>
Here @Peter describes a very cool way to use a <force:inputField ... /> together with
<aura:attribute name="YourObjectType" type="YourObjectType"
default="{ ...
7
votes
1
answer
13k
views
Number of iterations exceeded - Flow Error
I have a flow that loops through Opportunity Line Items. When the number of line items get large it get an error in my flow. The UI gives the following message "You or your organization has exceeded ...
6
votes
1
answer
4k
views
Why is my Lightning aura:iterate component not iterating?
Currently working through the Create a Standalone Lightning App tutorial, which seems a good introduction to SFDC Lightning, but not entirely flawless.
I have this component
<aura:component ...
6
votes
0
answers
87
views
Why can't a Queueable use an Iterator that comes from a Set?
I saw some surprising behaviour when storing the iterator obtained from a Set<Id> as a member in a Queueable class. So, I wrote the following trivial Queueable class to investigate:
public class ...
5
votes
2
answers
315
views
Looping Through A Map
I have a map I want to loop through and remove all duplicate items. Is there a method that can be used like my pseudo code has?
public Map<String, User[]> allPeople {
Map<String, User[]&...
5
votes
2
answers
18k
views
Expressions in for:each index value in LWC? [duplicate]
Currently, I am facing an issue is that I want index starting from value "1"
I am using for:each in my code.
<template>
<lightning-card title="HelloForEach" icon-name="custom:custom14"&...
4
votes
1
answer
1k
views
Lightning Aura Iteration ReRender
I am trying to rerender an iteration(wrapper) when an input field is changed although I am extremely unfamiliar with Lightning. Everything that I've read it "it should just work", which I don't ...
4
votes
1
answer
6k
views
How Custom Iterators with Iterable Work
I was reading the topic of using iterator and iterabel Interface - https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_iterable.htm
It says :
If you do not want ...
4
votes
1
answer
13k
views
Inserting Records using a lightning component
I am looking to make a lightning component to insert my Transaction__c object records against all relevant Contracts pulled back requiring action. As it stands I am returning all of relevant contracts/...
4
votes
1
answer
1k
views
Lightning Component - data binding not working on sObject [] for new element pushed in array
If I load a sObject array in init function, I m getting my array correctly filled and loaded to the UI using iteration. I create a new button to add (push) new element of the same type to the existing ...
4
votes
1
answer
773
views
How to get Map collection out of a list?
I currently have a multi-demensional map/list object that is defined like this:
Map <Id,List <Map <Id,Custom_Inventory__c> >> complexMap = getComplexMapObject();
The object was ...
4
votes
1
answer
798
views
aura:iteration index is empty
I'm trying to conditionally format my items in a Winter'17 Org based on a selected index. But comparing the iteration index to my selected index (v.Active) doesn't work.
I tried to output it and it ...
3
votes
2
answers
6k
views
LWC: detect last element in for:each iteration
I'm trying to output a list of strings separated by commas in LWC, such as:
cat, dog, mouse
I need to use template for:each and output a list item and a comma, but only if the item is not the last ...
3
votes
3
answers
10k
views
Adding/removing elements from a `Map` while iterating over it
Background
I'm working on a bugfix for some code that I've written. The code itself generally works fine (bugfix is for an edge case), and the exact code isn't terribly important for this question.
...
3
votes
1
answer
1k
views
Using next method in iterator
In my code below:
List<Skill__c> skilist = [ select Id,Name from Skill__c where Skill__c.Id IN:sl.keySet()];
Iterator<Skill__c> iter = skilist.iterator();
List<Job_Opening_Skill__c&...
3
votes
2
answers
232
views
How can I filter through object using 2 separate fields as unique identifiers?
I have a custom object (we'll call it RS__c), and it theoretically has a 1 to 1 relationship to OpportunityLineItems (it is not possible to create a reference field directly to create this ...
3
votes
1
answer
3k
views
How to use 'lightning-checkbox-group' in for:each loop?
Currently, my requirement is that I want a checkbox in front of names.You can see below screenshot.
So I used lightning-checkbox-group in iteration but it does not work.
Here is the Playground Link ...
3
votes
1
answer
2k
views
Unable to display custom object list attribute returned from client side controller
I am hung up on the hands-on challenge for the Lightning Component Basics > Input Data Using Forms section on Trailhead. I have a form with input controls for name, quantity, price, and isPacked ...
3
votes
2
answers
572
views
Pagination Using Iterator Limit
I have to paginate total of 4000-5000 records with 20 records per page. I am using a wrapper class type List. This list would be displayed on a pageblocktable.
I CANT use OFFSET because offset has a ...
3
votes
2
answers
2k
views
Iterating inside a Map
Big picture, upon importing a csv, we have some unique Id's that may be tied to an account already in our instance. I can iterate over a list with no issue and to find any unique Id's with a matching ...
3
votes
1
answer
536
views
This map cannot be used in an iteration because the keys cannot be sorted
In my apex code I am adding some value into map. And I am trying to loop through the map on VF page using apex:repeat but I am getting an error that
This map cannot be used in an iteration because ...
3
votes
0
answers
2k
views
ui:inputCheckbox and aura:iteration: value binding
I am currently writing a lightning component made of a table of elements that can be selected (or not) using a ui:inputCheckbox.
So the way I do is fetching the data from APEX controller during the ...
2
votes
2
answers
3k
views
Is there a Salesforce solution to Filter or Limit Aura iteration?
I am iterating through a list of items as follows
<aura:iteration items="{!v.objWrap}" var="item" indexVar="idx">
...
...
...
</aura:iteration>
I also want to have a load more button ...
2
votes
1
answer
786
views
Iterate related records, display images from string name of contentAsset in Community Cloud
I'm very new to Salesforce, so my apologies if my approach is all wrong.
I want to display a list of buttons with images using a lightening component in Community Cloud. The list comes from records ...
2
votes
1
answer
1k
views
Batch Job with Custom Iterable throwing error First error: Invalid conversion from runtime type CustomIterable to System.Iterable
I get the error First error: Invalid conversion from runtime type CustomIterable to System.Iterable when trying to use a customer iterable in a batch job.
My custom iterable class:
global class ...
2
votes
1
answer
6k
views
LWC create input fields under LWC iteration
I am new to LWC. I have to create multiple input fields for different rows. Let say, I have selected 3 records from the previous page and for all those 3 records I need to create the input field and ...
2
votes
2
answers
3k
views
Iterating over wrapper class records lists in LWC
I have a LWC where i want to iterate over different lists of Opportunities in a wrapper.
Currently im using:
import { LightningElement,wire } from 'lwc';
import OppRecords from '@salesforce/apex/...
2
votes
1
answer
37
views
How to check values from child object
I was wondering what would be the most efficient way to do the following.
The Account object is the parent of the Order object.
The Order object has a field called 'Status'.
The Status field, a ...
2
votes
1
answer
182
views
Updates from nested apex repeat in Visualforce not being posted to server correctly
I am having a custom object where there is a list within a list within a list.
On the Visualforce page I am presenting it using an apex:repeat and apex:inputText fields.
When I try to change and ...
2
votes
3
answers
2k
views
Iterate over queried lookup fields
Example:
Opportunity Opp = [SELECT Name, Status__c, Zone__c, Invoice__r.Amount__c, Invoice__r.Date__c FROM Opportunity WHERE ID ='006a12nlfoenlew'];
I need to iterate over each field and see if the ...
2
votes
0
answers
604
views
Get first row of CSV data in salesforce and use for mapping
I want to get data from csv and upload it to salesforce.
I use this link http://www.blueengine.com.au/?p=40#comment-271 and http://developer.financialforce.com/customizations/importing-large-csv-...
1
vote
2
answers
870
views
Exception not being caught; System.FinalException: Cannot modify a collection while it is being iterated
Why is this Exception not being caught?
I read that System.LimitException is not caught but didn't see anywhere about System.FinalException.
Non-Working Code
@AuraEnabled
public static List<...
1
vote
1
answer
1k
views
Aura:Iteration Tag Not Working
I am trying to display information from the users object, but I cannot get the components to cooperate. Code is below:
apex:
public with sharing class LACC_ObjController {
@AuraEnabled
public ...
1
vote
2
answers
866
views
Aura :iteration and :if, WARNING: Performance degradation..
I'm receiving a WARNING: Performance degradation: Multiple items were set in iteration message. This occurs in the code below when the aura:if element is there, but not when it isn't.
Each group ...
1
vote
1
answer
1k
views
Get all the Ids that were inserted by Database.insert - without iterating each record
We are using the Database.Insert(leads, false);
We want only the the ids that where insert. We have a lot of leads to be checked if we use
for (Database.SaveResult result: results) {
if (result....
1
vote
1
answer
22k
views
Copy a list to another list
I have a custom object called skill_Review and I am creating a list in my controller using:
List<Skill_Review__c> skillRev = new List<Skill_Review__c>
List<Skill_Review__c> ...
1
vote
1
answer
5k
views
LWC: Refresh for:each loops when new Array item added
I have 2 LWC components and loop through data in the following structure
periods
period.stages
stage.details
Within stage.details I render a table/form for each detail. After the table/form I have an ...
1
vote
2
answers
6k
views
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?
I was looking to do the following and I'm not sure if it's possible in LWC.
I have a list of records which I'd like to loop through in the UI. I also have a map of records where the key is the iD of ...
1
vote
1
answer
53
views
List iteration - item with space
I am trying to create a very basic static list to iterate through. One of the values has a space in it. I can't figure out how to add the item to the list with a space. In the example below, I can'...
1
vote
1
answer
111
views
Batch Class with Custom Iterator Not Using First Element?
I have been hitting my head against the wall with this one.
I have a batch class that runs against Leads, Contacts, and Accounts as well as 2 external objects. I created a CustomIterator to accomplish ...
1
vote
1
answer
1k
views
LWC Change iteration to color even indexes
I am trying to find how to change the row color of even rows so it alternates between odd and even indexes in my list of divs so odd would be a background of say white and the evens would be a ...
1
vote
1
answer
2k
views
LWC Nested Iteration Issue
I am facing an issue with the nested iteration,
Suppose I have one button in child loop and i want index of parent and child loop both in onclick function of JS file.
I am only getting index of child ...
1
vote
2
answers
641
views
LWC for:each needs 3 levels, but SOQL query aggregate relationship limited to 2. What's your best practice?
so I have a structure like:
<template for:each={containers.data} for:item='container'>
<....> //container info
<template for:each={container.Pallets__r} for:item="pallet"&...
1
vote
1
answer
1k
views
Bulk Apex iterator not working with aggregate query
I am at a bit of a loss at how to properly structure a batch apex query with an iterator in order to utilize batch apex with an aggregate query.
This is my current code
Iterator
global class ...