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 votes
2 answers
50 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,294
0 votes
1 answer
57 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
  • 25
-1 votes
1 answer
65 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
140 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
66 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
47 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
151 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
  • 97
0 votes
1 answer
64 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
  • 63
0 votes
0 answers
42 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
115 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,294
-1 votes
1 answer
150 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
109 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
52 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
  • 11
1 vote
1 answer
42 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
155 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
139 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,473
0 votes
2 answers
131 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
1k 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,765
1 vote
2 answers
238 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,294
1 vote
2 answers
144 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
14 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
  • 97
2 votes
1 answer
160 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,179
0 votes
0 answers
672 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
593 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
70 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
124 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,294
0 votes
1 answer
89 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
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
118 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
220 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
534 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
  • 145
0 votes
2 answers
325 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
  • 145
1 vote
1 answer
56 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
78 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
359 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
4k 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
78 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
760 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
118 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
222 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
150 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,294
0 votes
1 answer
60 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
965 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,761
1 vote
1 answer
58 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
370 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
4k 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
  • 631
0 votes
1 answer
373 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
  • 353
0 votes
0 answers
126 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,555
0 votes
1 answer
255 views

ContentBlockById and For Loop

I have a problem with this Loop because there are 8 rows in the DE and when I execute the code below, the preview only shows 6 content blocks. The last one it displays, also has a loop inside and ...
Constanza Sosa's user avatar

1
2 3 4 5
7