Skip to main content
New
Stack Overflow Jobs powered by Indeed: A job site that puts thousands of tech jobs at your fingertips (U.S. only). Search jobs

Questions tagged [loop]

A loop is a sequence of instructions that is continually repeated until a certain condition is reached.

Filter by
Sorted by
Tagged with
1 vote
1 answer
123 views

How to recursively iterate through multi nested arrays in the lwc's html file?

I have the following data and nested a way to recursively call the same logic so that regardless of how many levels are in the data, the data is always printed correctly in a nested format. Example ...
usernameabc's user avatar
-1 votes
2 answers
99 views

System NullPointerException on get from map

I have a nullpointer exception in the following code on line if(mapSoldAppStatus.containsKey(user.Id)){: Map<String,Map<String,Integer>> mapSoldAppStatus = ReportPageController....
Thomas's user avatar
  • 2,298
0 votes
1 answer
378 views

Map value to specific variable in loop within Flows?

Working on a flow in which I need to iterate over up to 12 records and sort it in descending order by date. Then take a single value from each record and store it. I will then update the parent record ...
stormy's user avatar
  • 51
-1 votes
1 answer
296 views

Salesforce LWC nested for each loops with if condition

I am trying to implement a listbox in LWC. The list box is showing values from a picklist in Account object. On click the value of the selected item is adding to an array. But on the UI it is not ...
Hasan Zubairi's user avatar
-1 votes
1 answer
701 views

How to use loop within a loop in salesforce flow?

Requirement: A note will be created for a selected account from the list view, using a custom button. This button calls a VFPage & that vfpage calls this flow. My current output creates the ...
yash jagtap's user avatar
-1 votes
2 answers
420 views

How to iterate on a custom number field on an account using flows and not trigger

Creates the number of contacts which are equal to the number which we will enter in the Number of Locations field on the Account Object. This is the trigger but i have been assigned to convert this ...
Harman Chahel's user avatar
0 votes
0 answers
74 views

Tip still showing Database access elements in loop

I have a loop in a flow where I have multiple Get elements which are clearly placed after the "After Last" path when the loop is complete. But the Flow 'Tips' is still telling me almost ...
Suzie's user avatar
  • 11
1 vote
1 answer
330 views

LWC - How To Loop Through A List With data-aura-rendered-by attribute?

is there any way we can loop through a list of object with this code snippet? It works okay when the list return 1 record. However, if the list has more than 1 record, it cannot rendered (display). ...
Pam's user avatar
  • 107
0 votes
1 answer
86 views

Looping SSJS to output Ampscript variables partially works if I don't use a word building array function. Can't figure out why

I've got a data extension which has multiple rows for each item a user has in their cart and it's tied to their email address. The main issue is I need to cut off the product name at a max character ...
Erik B's user avatar
  • 65
0 votes
0 answers
98 views

Trying to understand how to bulk update via a schedule trigger flow

I created a schedule trigger flow to update 1000s of opportunities every night. The job of this flow is to find any inactive opportunity and close-lose it. However, I am hitting "...
Ty Haas's user avatar
0 votes
1 answer
755 views

How to iterate over map with id and Sobject list

I have the following piece of code: map<id,List<Spot__c>> spotMap = new map<id,List<Spot__c>>(); List<application__c> apPList = [SELECT ID, Account__r.id,(SELECT id,...
Thomas's user avatar
  • 2,298
-1 votes
1 answer
545 views

Avoid Hitting the Limits when Updating records with a Scheduled Flow

I have to change the status of some tasks after 30 days. I have already created and tested the flow in my sandbox, the problem I'm having is that in Prod we usually have around 5000 records to expire. ...
Rocio's user avatar
  • 3
-3 votes
1 answer
196 views

How change this nested for loop to map

I took this code from another question asked in this site My code is similar to the below. Please say how to change the nested for loop used in this snippet to map. trigger OpportunityTrigger on ...
Sushil's user avatar
  • 3
0 votes
1 answer
59 views

Extract Particular value from the result list and store them in another list

Hi I have a list type of List which is returned from the invocable action. List<Invocable.Action.Result> results = action.invoke(); I am getting the data as below in the form of result. (Result&...
Shekher's user avatar
  • 23
1 vote
1 answer
90 views

Flow loop collection - can it be a decision as to which collection to run loop on?

Background: Flow as Lead Router(aka Round Robin) by Program Rules have members (users) who may be active or inactive (think out of office, not user account) If a program is matched to a rule but there ...
Suzie's user avatar
  • 11
-1 votes
1 answer
377 views

I am trying to re-start an existing loop to iterate through it again with a new comparison value

Problem- Looping through a collection of values looking for a matching value to a previously assigned variable. It is possible a match does not exist. The variable value is now changed and I need to ...
Suzie's user avatar
  • 11
1 vote
1 answer
140 views

Rusty Coder - Better way to avoid soql in loop

I haven't had to write any code in a few years now and I have to believe I am not using the best approach to avoid a SOQL query in the loop. I am doing a query outside of the loop and then iterating ...
Matt M's user avatar
  • 1,477
0 votes
2 answers
210 views

How to avoid nested for loop in this apex code?

public class TestUserData { public static HttpResponse makeApiCallout(String endpointUrl){ HttpRequest request = new HttpRequest(); App_Id__mdt appid = App_Id__mdt.getInstance('appid'); ...
sahil kakadiya's user avatar
1 vote
1 answer
2k views

LWC conditional check in for:each on field content

I have an LWC in which I need to check the value of a field in a for:each loop to determine what to display in the HTML. I've tried to find a solution but haven't had success so am hoping someone will ...
Irene's user avatar
  • 1,839
1 vote
2 answers
336 views

How to address null-pointer exception

I Have the following apex code which is throwing a nullpointer exception on the line: points = points + value; List<JMG_ExternalSearch__c> searchList = [SELECT Id,LastModifiedDate,...
Thomas's user avatar
  • 2,298
1 vote
2 answers
174 views

SOQL FOR LOOP with Selector Class

I am building a SOQL FOR LOOP and I am wondering whether or not I am getting the advantages by abstracting the SOQL Query to a separate Selector class. Should I instead be placing the SOQL Query ...
Coova's user avatar
  • 180
1 vote
0 answers
15 views

Avoid iterating over list inside loop [duplicate]

Hello guys I have two lists. One has contact records and other has ContentVersion records. What I need to do is that by every contact I have to create a documents and attach to them by using the ...
TechGuy's user avatar
  • 107
2 votes
1 answer
256 views

Transform a List<String> for use in Multi-Select Picklist where clause

I have a list of strings which I need to put together in every valid combination so that the result can be used in an includes WHERE clause of a multi-select picklist in a SOQL query. Basically, I ...
Mike's user avatar
  • 1,199
0 votes
0 answers
1k views

Screen inside Loop in Salesforce Lightning Flow

I'm trying to create a survey form using screen flow and for that I'm fetching the Question records from Question custom object and trying to show Questions as text along with their options as radio ...
kunal's user avatar
  • 75
0 votes
0 answers
815 views

Error Occurred During Flow: Apex CPU Time imit exceeded

I am receiving this 'Apex CPU time limit exceeded' error on my flow Flow: Flow start object record filtering Get Records I am collecting the Product2 records with some conditions and iterations it ...
Yogesh Sakat Aphidas's user avatar
0 votes
2 answers
72 views

Can this nested loop be done through a map?

I have the following bit of code which is a nested loop that I'd like to know if it can be replicated by using a map instead as I haven't used them before and would like to know how it would end up ...
qnt13's user avatar
  • 3
-3 votes
1 answer
186 views

How to prevent loop in batch correct way [duplicate]

I have the following Batch which currently runs. I am still wandering if the way I set my for loops are correct. Is this solution the right way? I have a Quote which is related by several amount ...
Thomas's user avatar
  • 2,298
0 votes
1 answer
95 views

Remove SOQL query inside a loop

I am coding a HttpPatch and I need help to remove the query inside the loop (line 13). Is it possible? @HttpPatch global static void EstablishmentUpdateDelete( String actionType, String cuit, ...
Gonzalo's user avatar
  • 15
0 votes
1 answer
2k views

Loop through records in a flow and append to text to send in a single email

I'm attempting to do the following in a "Scheduled-Trigger Flow": Send a list of Campaign Members that meet a certain criteria in a single email. Example: John, Jane and Jared are ...
markwilland's user avatar
0 votes
1 answer
153 views

Lightning Web Components/LWC (no aura): How do you set the maximum length of list when rendering with iterator?

How do you set the maximum length of a list with LWC? I understand in Angular you could use "ng-maxLength". <template iterator:item={records}> <!-- List up to ten records --> ...
Eric's user avatar
  • 1
2 votes
2 answers
255 views

How can I dynamically upsert data in object

I want to upsert data in SF based on the selected columns by the user. I make HTTP callout to an external service and it returns the data. Then, I want to iterate over the each returned row and create ...
Stojchesky's user avatar
0 votes
1 answer
714 views

How to retrieve JSON values from a Data Extension

I have a basic javascript for retrieving values. Like this: <script runat="server"> Platform.Load("core", "1.1"); var list = ["value1",&...
Martijn e's user avatar
  • 143
0 votes
2 answers
413 views

Is there a way to parse JSON without names?

we have a simple JSON structure. This structure has no names like this: ["value1","value2"] Is there a way to parse/use this in Marketing Cloud? We don't have to make decisions. ...
Martijn e's user avatar
  • 143
1 vote
1 answer
65 views

Only showing those that Return true from a FOR AmpScript

I am searching a data extension based on an ID and returning vairables and a link from those. I was able to get it to pull all the required data and show correctly. However when I try to add a ...
Connor Tom's user avatar
2 votes
1 answer
83 views

Reducing loop runs and code repetition in a trigger where junction records are created which match several criteria

I'm new to Apex and coding in general and trying to get the best practices down where possible. This trigger challenge came from David Liu's Apex Academy series and gives the following requirements: ...
cwrcyn's user avatar
  • 21
-1 votes
1 answer
464 views

Unable to get triggering records in Before Insert(Fast Field Updates) and loop over them [closed]

I was trying by using "Get Records" elements to get all the records of the object triggering the flow. But as the record is not being inserted yet, I can't filter it via Id. Is there any ...
Muskan Agarwal's user avatar
1 vote
3 answers
6k views

Is there a way to update a bunch of records without loop in flow

I want to do an update of a set of records on a daily basis with a flow. We are talking about 5,000 records on a batch. The issue I'm having is that when I assign the individual records to a variable ...
ErFran's user avatar
  • 81
0 votes
2 answers
90 views

Simple Apex code snippet not behaving as expected

Integer delay = 1; for(Integer i=1;i<=5;i++) { System.debug('Print '+i); Long sTime = System.now().getTime(); while ( (System.now().getTime()/1000 - sTime/1000) < delay){} } When ...
Suhasini's user avatar
  • 307
0 votes
0 answers
902 views

Help with 'Update Records' element after a flow with loop

I'm relatively new to flows and super new to loops. I've watched several flow tutorials and they all seem to follow the pattern of: a record is triggered > loop through related records > assign ...
Jenny Jo's user avatar
-1 votes
1 answer
123 views

how to merge two For Loop

if(sObjectType == 'Order') { List<order__c> list_Order = new List<order__c>(); // todo=merge both the for Loop for(SObject obj : s_object){ order__c ...
sunny roxx's user avatar
0 votes
1 answer
261 views

How do I get recordtype in a loop?

I am getting Variable does not exist: recordType exception in for loop public void getGroupCallCustomers() { leftValues = new map<string,string>(); rightValues = new map<...
narojoc807's user avatar
0 votes
1 answer
161 views

How to fetch soql value of subquery in javascript

I have the following soql @AuraEnabled(cacheable=true) public static List<AggregatedResult__c> getTarget() { Id currentUserId = UserInfo.getUserId(); String query = '...
Thomas's user avatar
  • 2,298
0 votes
1 answer
69 views

Nested for loops

I would like to associate all the contacts with name test in them to an account. trigger trg1 on Account(after insert){ List<Contact> conList = [Select Id,LastName from Contact where ...
zain ahmed's user avatar
0 votes
0 answers
1k views

Get the sum of a currency field of all related Opportunity childs and grandchilds using a flow

I just started my flow journey and I can't find a solution to my problem. I have two different opportunity types. In type A I want to display the sum of the Amount field of all the subordinate records ...
Chris St.'s user avatar
1 vote
1 answer
2k views

Issue with Loop and display of list Using Salesforce flow

I have the below salesforce flow: What the flow is trying to do: On the first screen get the Account name and account number If Acc number = 1 then assign acc values to a record variable ...
SfdcBat's user avatar
  • 4,811
1 vote
1 answer
62 views

Logic problem, it is possible? Add more quotelineitems if it has more than 1 on quantity

Hello Guys. My method does not work correctly. What it does is call another method inside a loop, the functionality is to take each quotelineitem from the quote until it finishes collecting all the ...
Alex Barón's user avatar
0 votes
0 answers
440 views

CPU Time Limit Exceeded Trying to Email 2000 Contacts

I have a junction object called AccountContactRelation which is linked to both the Contact and Account objects. I am trying to sort through the accounts, and for each one, add all the related ...
Austin Kelly's user avatar
2 votes
1 answer
5k views

Can you iterate over object properties in LWC?

I know you can use the for:each directive to loop through Arrays, but is there some way to loop through an object's properties?
jbyrd's user avatar
  • 641
0 votes
1 answer
454 views

Date.addDays not working in a loop

I have this code that creates opportunities for every day given a period start and end date. However I see that the addDays is not working as the resulting value is the same as the start date. Why ...
Pauline's user avatar
  • 375
0 votes
0 answers
157 views

Two level iteration not working in LWC

I have two level of iteration in LWC, and the second iteration is not displayed even if there are contents in it : <template for:each={calendarCol} for:item="ccd"> &...
vanessen's user avatar
  • 2,685

1
2 3 4 5
7