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
1 answer
36 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 ...
user avatar
0 votes
0 answers
32 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 ...
user avatar
1 vote
1 answer
61 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 ...
user avatar
  • 4,521
1 vote
1 answer
46 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 ...
user avatar
0 votes
0 answers
18 views

Add quotelineitem depending of 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 ...
user avatar
0 votes
0 answers
55 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 ...
user avatar
0 votes
0 answers
21 views

Flow won't move onto next element after last item

I have created a flow with a couple of loops, however the flow doesn't seem to move to the next element at the end of the loop, and instead ends the flow.
user avatar
1 vote
1 answer
202 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?
user avatar
  • 471
0 votes
1 answer
37 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 ...
user avatar
  • 197
0 votes
0 answers
47 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"> &...
user avatar
  • 2,393
0 votes
1 answer
45 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 ...
user avatar
0 votes
1 answer
34 views

Given a date, return the ID of the record that is within the Start and End dates

Object Name: Dates__c Fields: Id, Start_date__c (date), End_date__c (date), Week__c (string) Objective: Given a Date e.g '2022-01-07' from an object table that has input as so... Id Start End Week # ...
user avatar
0 votes
2 answers
69 views

Why does my array not show up in the template for:each?

I am trying to get a value from a list of objects to show up on the html page using the for:each directive. I have a then method that dynamically builds an array of objects that holds an id number and ...
user avatar
  • 41
2 votes
0 answers
300 views

Cannot reference a field from currentItem in the new Collection Filter node

I am trying to update a field on the triggering object using a Flow. I have filtered my options using a Collection Filter and it returns a single item. When I then try to assign it, it displays as a ...
user avatar
  • 21
0 votes
1 answer
122 views

Can I deep clone a record but set the ID?

I have two account records. I want to move all of the data from account #1 into account #2. Is it possible to do a deep clone and set the ID? Or would I have to loop through account #1 and pull the ...
user avatar
  • 3,179
0 votes
1 answer
400 views

Apex - Loop Through List and Set of IDs

I have a set of IDs and a soql to get list of accounts for those IDs: Set<ID> setOfIDs = new Set<ID>{//AccountIDs}; List<CustomObj> lstCustObjDetails = [Select ID, Name, Record__c,...
user avatar
  • 15
0 votes
0 answers
30 views

How do I get service appointments for each and every resource in work type ? (Field Service and Flows Concept)

The process works like this, I created a new field called as, “Number of Resources” in work order and I would like to get appointment for each resource. For example, if the user types Number of ...
user avatar
0 votes
1 answer
95 views

looping over dynamic soql of indeterminite dimensions

Hoping someone has a clever strategy for the following scenario - I have a dynamic soql query that when assembled could be either: soql = 'select id from a'; soql = 'select id, (select id from b) from ...
user avatar
  • 51
1 vote
2 answers
156 views

What is the difference between soql for loop vs soql list

As per the documentation it mentions ) (soql for loop) retrieves all sObjects using a call to query and queryMore whereas (list for loop) retrieves a number of objects records. It is advisable to use (...
user avatar
  • 11
-2 votes
1 answer
61 views

Hi guys, can you please help me rewrite the nested loop from the end of the codes [closed]

//triggers rigger MaintenanceRequest on Case (after update) { MaintenanceRequestHelper.updateWorkOrders(Trigger.New); } public with sharing class MaintenanceRequestHelper { public static void ...
user avatar
0 votes
1 answer
57 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 ...
user avatar
  • 21
0 votes
1 answer
63 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 ...
user avatar
  • 23
0 votes
2 answers
66 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 ", ...
user avatar
0 votes
0 answers
40 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, ...
user avatar
0 votes
1 answer
44 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 ...
user avatar
  • 1
0 votes
1 answer
293 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,...
user avatar
0 votes
0 answers
26 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 ...
user avatar
  • 113
1 vote
1 answer
952 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: ...
user avatar
  • 113
0 votes
1 answer
132 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 ...
user avatar
  • 113
0 votes
0 answers
42 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....
user avatar
  • 3,179
0 votes
2 answers
154 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')....
user avatar
  • 1,081
1 vote
0 answers
156 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 ...
user avatar
0 votes
0 answers
101 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 ...
user avatar
  • 113
0 votes
0 answers
39 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 ...
user avatar
  • 1
0 votes
1 answer
24 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); ...
user avatar
0 votes
2 answers
117 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 } } ...
user avatar
0 votes
2 answers
115 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 ...
user avatar
0 votes
1 answer
106 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. ...
user avatar
1 vote
1 answer
66 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 ...
user avatar
-2 votes
1 answer
70 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; ...
user avatar
1 vote
1 answer
32 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: ...
user avatar
1 vote
1 answer
619 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 ...
user avatar
0 votes
0 answers
52 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: ...
user avatar
  • 107
0 votes
1 answer
35 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){ ...
user avatar
-4 votes
1 answer
40 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; ...
user avatar
0 votes
1 answer
801 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; ...
user avatar
6 votes
2 answers
565 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 ...
user avatar
4 votes
2 answers
121 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 ...
user avatar
0 votes
1 answer
228 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? ...
user avatar
0 votes
1 answer
135 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 ...
user avatar

1
2 3 4 5
7