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
0
votes
1answer
40 views

Re-Parenting in a loop

I need to update another developer's code that is running up against the Apex CPU limit when dealing with a large number of accounts. The code itself fired on afterUpdate trigger on the Account ...
0
votes
1answer
41 views

Two inner loop need to replace with map.can we? [closed]

I am new to coding.here i want to replace the two for loop using map.can we do it? ContentVersion versionIn = [ SELECT VersionData, VersionNumber, PathOnClient FROM ContentVersion WHERE ...
0
votes
2answers
57 views

Need help moving SOQL out of the loop

Hello, I need move this query out of loop: List<Lead> dupeLeads = [SELECT Id, Email FROM Lead WHERE Id != :Ld.Id AND Email =: Ld.Email]; I'm testing various guides on "bulkifying ", ...
0
votes
0answers
35 views

Attempt to de-reference a null object but no issues found in the class

I have a Class1 and then there is another Class1_Handle. The Class1 takes a list of OPP, then loops through that and sends Opportunity ID to the Hadelar 1 by 1. The Handler then does a bunch of stuff, ...
0
votes
1answer
32 views

How to Retrieve the table same as excel table into an email using ampscript?

How to output excel table as table into an email using amp script code? but each week the number of products I feature could change up or down, how could I build the email so that it can pull in each ...
0
votes
1answer
40 views

Variable does not exist error when trying to retrieve the value from the list

List<SBQQ__QuoteLineConsumptionRate__c> quoteLineConsumptionRates = [SELECT id, SBQQ__LowerBound__c, SBQQ__UpperBound__c, SBQQ__Price__c, SBQQ__QuoteLineConsumptionSchedule__r.SBQQ__QuoteLine__c,...
0
votes
0answers
24 views

Some one good in flow help me please, the decision element is always taking the default path [duplicate]

Lets say I have contact1 and contact2 who have picklist stages [ New, Open, Prepecting, Nurture] in a account. Account also have similar stages form picklist. I would like to align the furthest stage ...
1
vote
1answer
101 views

In a flow, collection variable contains what it is supposed to but skips decision outcome, how would you handle it?

"Open" Outcome conditions Does Require Record Changed to meet criteria: true {!contactsStageText} ([Open]) Contains Open Skipped this outcome because its conditions weren't met: EDIT: ...
0
votes
1answer
26 views

How to filter through a collection picklist in flow, just to get the desired value?

My collection picklist variable at the end may look like, (New,New,Open,Prospecting,Propecting,New,Nurture, Demo Booked, Opt-out, Opt-out) I need to get just one value from these which is the highest ...
0
votes
0answers
32 views

Refactor Nested For Loops Help

I am trying to unwind a multitude of nested loops and one of which that is causing CPU timeouts is the one listed below. I know I need to make a map outside of the loops and then call mapNameOfOldLoop....
0
votes
2answers
55 views

How to switch on RecordTypeId inside a loop?

Alternative Title : How to optimize grouping each SObject records by Recordtypes public static Id sgRecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Singapore')....
1
vote
0answers
29 views

How to add seperate comma in list value after loop and input data in list?? -FLOW SALESFORCE

i am newbie in salesforce, I do a loop and store the data in a collection variable (multiple). but when the data is added the list is not separated by commas. Example of the resulting output: Data ...
0
votes
0answers
46 views

Opportunity Team and Opportunity Split from a Partner field in Opportunity. Which should be preserved even if the opportunity owner is changed

what I am trying to achieve is whenever a "Partner" field is changed, it should get reflected in Opportunity Team and Opportunity Split. Meaning that When a "Partner" field in ...
0
votes
0answers
23 views

Submitting multiple records from a button

I have a listview URL button that calls a flow and that flow adds bunch of contact records to the custom Project object as a Project Member. It is a screen flow. You select which project and the flow ...
0
votes
1answer
18 views

Create a method that invert 2 elements in a List<Integer>, should return the list with the numbers inverted.(indexes + list are passed as paramethers)

The goal is to invert 2 elements of a List. Like if I have List<Integer> integers = new List<Integers>{1,2,3,4,5,6,7}; If I call this method: invert(List: integers, index1: 2, index2: 3); ...
0
votes
2answers
70 views

Null pointer exception inside for Loop

Here is the code: for(Requests curRequest : requestList){ if (curRequest.varSRProduct!= null ){ for(SObject so : curRequest.varSRProduct){ //code } } ...
0
votes
2answers
27 views

Nested select record for each element in list

I have some List with values and i need to get record from sobject for each element from that list. So it looks like that. But its very close to limitations. Any ideas gow to do it? Its necessary to ...
0
votes
1answer
75 views

How to avoid for loop inside for loop in the below code

Claim and Review are two objects a claim can have number of Reviews and a Reviewer can have have multiple claims. My requirement is weekly send notifications to reviewers for their approval on claims. ...
1
vote
1answer
55 views

Three FOR loops in ampscript after reading from XML

I have an eReceipt issue. I am able to get the nested loop to work to display the promo amounts and descriptions when there is only one promo per item purchased. Where I am stuck is trying to add a ...
-2
votes
1answer
44 views

For loop should iterate twice with one value in apex code [closed]

here is my code. accountList[1].ParentId = accountList[0].Id; accountsToUpdate.add(accountList[1]); accountList[2].ParentId = accountList[0].Id; ...
1
vote
1answer
23 views

Search List for variable for comparison using contains

I am trying to find the Name variable in a list to use the contains() method to search for the Name of the Activity_Assignment__c but am getting an error: Method does not exist or incorrect signature: ...
1
vote
1answer
76 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 ...
0
votes
0answers
35 views

Transpose coloums to rows within a loop to create a table for a cloudpage

I trying to create a simple overview in a cloud page of all emails sends from marketing cloud. Using data views tables, I have created a DE called "Sent_rapport". It looks like this: ...
0
votes
1answer
34 views

Salesforce too many soql queries 101 whle inserting bulk data. I need to check if the contact is all ready present or not before inserting a new conta [closed]

public static void ContactFromAccount(List<Account> NewAccountList){ list<Contact> contactList = new list<contact>(); for(Account a : NewAccountList){ ...
-4
votes
1answer
38 views

Explain this code for me [closed]

DateTime earliestCreated = events[0].CreatedDate; for(integer i = 0; i < events.size(); i++) { if(events[i].CreatedDate < earliestCreated) index = i; ...
0
votes
1answer
224 views

dynamically created query in APEX and Update the Value

Dynamically created query in APEX and Update the Value. Trying to update field value by string objectName = 'Account'; list<sobject> recordsList; string condition = 'id IN:' + recId; ...
6
votes
2answers
294 views

FFLib Selectors with SOQL For Loops

I'm considering implementation of FFLib, or at least parts of it, throughout our enterprise. Right now I'm focusing on the Selector and Query classes to consolidate our SOQL into a Selector Layer. I'm ...
4
votes
2answers
80 views

Javascript loop very inefficient......Why? [duplicate]

I am not a javascript expert but thought this was a slam dunk to code until I saw the results. I am looking for help to make this MUCH more efficient. I have a simple for-loop going over a list of ...
0
votes
1answer
119 views

How to draw fields of different types using for:each in LWC

I'm trying to draw a set of different fields (with type text, number, picklist and other) using for:each, but I get all identical fields (they differ only in names and labels). How can this be fixed? ...
0
votes
1answer
70 views

AMPScript loop to concat only non empty fields in a row

I am trying to concat all the non empty field values from a row in my DE, into a single variable (each value in the concatenated string separated by a comma). The field names are: FIELD1, FIELD2 and ...
10
votes
1answer
179 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 ...
0
votes
1answer
33 views

how to loop through a list of lists of different objects?

Let's say I have several different lists of objects: typeA[] Alist = [ ... ]; typeB[] Blist = [ ... ]; typeC[] Clist = [ ... ]; And I want to perform the same operation on each list: for (List<...
0
votes
1answer
101 views

AMPscript LookUpOrderedRows and Loop: if statement to check all values of a field

I'm a real novice with AMPscript, and I have some that works for listing items on an order for one customer in one-to-many relationship. Now I have another challenge, and I need to add something to ...
0
votes
0answers
30 views

Why I cannot update the Account ID on this for loop?

for (Account acc : newAcc_lst) { System.debug('to15format Test 1-> ' + acc.id); Id to15convertString = acc.id; System.debug('to15format Test 2-> ' + to15convertString); String ...
1
vote
1answer
46 views

Map has 2 of the same keys [closed]

I retrieved a list of records that have a lookup to a parent record with a unique id. Parent record --<Child Records. I have a map that has two of the same key in it. I'm not sure how to understand ...
0
votes
0answers
30 views

Set value from collection variable to the choices in picklist field using Loop

I am using an apex action that returns a list<list> which I am storing in a simple Collection variable. I want these string values to be acted as values in a picklist field (dropdown) that is ...
1
vote
1answer
47 views

Better Code for Comparing Multiple Opps and All Their Products?

Trying to compare all Opps and their OLIs to see if there are duplicates (Opps with certain data that is the same, and all OLIs have same product and quantity) and then mark them as potential ...
0
votes
0answers
18 views

Update Case field Number automatically based on child record (Task related to Case ID) by iteration in a flow

I'm trying to create a record trigger flow. My use case is to update automatically a field (Data type : Number) found in the Case depending on the number of records which have a type of Task. If the ...
0
votes
3answers
57 views

avoid inner loops with map?

I'm trying getting used to not creating inner loops in apex. Assume i have a Parent object Account which has child object Contacts. On Contact object i have a picklist value, with values "abc&...
0
votes
1answer
199 views

Add a row inside a table and a LWC Template

I was wondering if there is a way to add a row on a click of a button inside a LWC Template. I am able to make it work with a simple table but when I try to loop through an array and create a row of ...
0
votes
0answers
28 views

AMPScript: Can I cast a value as a variable?

I'm doing a lookup of a data extension and bringing a name-value pair back in my code. Is there a means of casting the result as a variable name? FOR @preferencePageIndex = 1 TO RowCount(@...
0
votes
1answer
69 views

SOQL to be outside of for loop [duplicate]

I am new to Apex and I am trying to make SOQL to be outside of FOR Loops but then my trigger stopped working. Here is my code: trigger AccountFieldUpdate on Contract (after insert, after update) { ...
0
votes
1answer
138 views

Update Household Naming Order in NPSP

I would like to update the Household Naming Order field in NPSP. This field controls the order of contacts, which in turn informs the household salutation field (among others). My code successfully ...
2
votes
1answer
310 views

How to avoid nested for loop condition for code Optimization?

public void execute(Database.BatchableContext BC, List<FinServ__FinancialAccount__c> scope) { Set<String> Acc_Numbers = new Set<String>(); Map<String,List<Id>...
-3
votes
1answer
61 views

Populate output of all values in the loop in SSJS

I have the following code and I would like to get all the values in that loop as output. Can someone tell me the function/process we use to get that result? <script runat="server"> ...
0
votes
1answer
44 views

How to retrieve the Account id

I need to retrieve the Account id and insert it to my method. Get the Basket__r.Account__r.id and place it to the Account id inside the for loop. How can i do that? list<Configuration__c> conf = ...
0
votes
2answers
208 views

i am getting this error System.FinalException: Cannot modify a collection while it is being iterated

//write trigger on contact when we edit contact. the contact name comes along with account name trigger ContactNameWIthAccountName on Contact (before update) { List<Contact> listOfContact = ...
0
votes
2answers
208 views

Trigger with bind Variable

I created a trigger on account object, that needs to populate a number field called 'ContactPhones'. The input of ContactPhones, must be equal to the related contacts of the inserted account, with the ...
0
votes
2answers
1k views

How to iterate a loop in a flow

I am very new to flows and I'm not yet still familiar with its workings. So I have flow that has a loop that supposed to iterate depending on the User's decision. As you can see from the image below, ...
0
votes
1answer
65 views

for loop pulling through Array in to table

I'm trying to build a loop that goes through a field that contains multiple labels and values, the outputs are not correct and I can't figure out why. can anyone help? %%[ SET @str = "label:a,...

1
2 3 4 5 6