The Stack Overflow podcast is back! Listen to an interview with our new CEO.

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
0answers
51 views

How To Optimize Looping?

I've written a utility class that enables a Custom Metadata Type mapping for Object to Object data cloning. I'd like our Admin team to be able to add/create/adjust the Fields on either object without ...
1
vote
1answer
74 views

Converting list into Integer

I have 2 string fields in database one is a name and the other is semicolon-separated values, I want to put the name and its summed up values in a map to use it later in the code. I can split the ...
0
votes
1answer
30 views

Access index of sObject collection using flow builder loop

I'm using process builder to auto launch a flow. I pass an id to the flow and use the getRecords element to query for a collection of records that returns the records in descending order based on a ...
0
votes
1answer
37 views

Iterating Through a Map<Id, List<Contact>>

This is a concept I am having a bit of trouble understanding. In this particular case I have debugged each piece within it and I can get the values I expect, But I am not able to iterate through them ...
0
votes
4answers
41 views

Is there any way to retrieve sum of grandchild field values on parent object

I am trying to iterate from parent to grandchild. Is there any way to do this as I want to show the sum of grandchild field value on parent object. please suggest me the best solution to do this other ...
1
vote
2answers
50 views

How to restrict duplicate emails entering into loop?

Could anyone help on this issue. In the below apex class I have method called getWrapAccounts().In this method for loop allows duplicate values.I have a Login__c field,It is emailID based on thid id ...
2
votes
2answers
59 views

Visual Flow - How to Loop Over Two Record Collections and Use Field Values From Both

I have a record collection for Object A, which I loop over and for each record in that collection I create a new record for object B. These records are assigned to a second record collection. At the ...
2
votes
1answer
85 views

Concat Loop Results to determine if contains value

I have the following code to retrieve the series of a product that has been purchased. We are using a loop because a contact might purchase multiple products. %%[IF NOT EMPTY(@PersonAccountId) ...
1
vote
2answers
57 views

Ampscript FOR Loops results to retrieve product using a second Loop

I have 3 salesforce objects: - PersonAccount - MyWatches (Fields:PersonAccountId, ProductId, Status = Owner) - contains the list of watches bought by the PersonAccount - Product2 (Fields: Series) - ...
0
votes
1answer
27 views

Flow Challenge: Trying to loop a single records fields values to do different actions

I'm working on a project to send emails to customers based on whether or not a user checks a certain box(es); I have 4 boxes in total they could check. Problem: Have user be able to trigger flow ...
1
vote
1answer
75 views

LookupRows loop on Entry Data extension and Lookup Data extension

I have two data extensions. Entry Data extension | CONTACT_ID | +------------+ | 1 | | 2 | | 3 | +------------+ Lookup data extension +------------+-----------+ | ...
0
votes
0answers
22 views

'For' loop: using AMPscript block instead of inline

Our case is inserting multiple orders related to single Customer_Id. The ask here is that we would like to use a complete AMPscript block, if possible, instead of combining inline and block-style in ...
1
vote
2answers
59 views

Incrementing a SET Variable

I understand For loops, but I'm struggling trying to set n SET variables. Basically, what I'm trying to do is for each @i in a rowset, I'm trying to: SET @SegLocator (and concatenate @i to the end) ...
0
votes
1answer
61 views

How to nest maps and display them in visualforce page

I need to display a a 4 level deep relation on a visualforce page from the parent showing the child relations. Account>property__c>Booking__c>Order>OrderItem. Since we can only go 1 level deep with ...
0
votes
1answer
46 views

How do I dynamically iterate through a subquery [duplicate]

This is the server-side code for a lightning component. Normally I would return the last line, but its commented out here to test using anon execution I think I am calling the parent Id in the loop ...
0
votes
1answer
45 views

How can I count number of “ !=null ” fields on a record?

My question is about challenge when Opportunity is created specific fields must be populated. How can I count the fields which are not null from specific fields? integer counter; integer oppValue; ...
-4
votes
1answer
73 views

Trigger not creating a new record [closed]

If case status got change for certain record type, new support record should get created. I configured status and record type combination in custom setting I am trying to avoid nested loop in my ...
0
votes
2answers
44 views

Flow loop with formula returning null value

I have a Flow which loops through a collection of custom Objects. In each iteration it gets an exchange rate from custom metadata. I then need to multiply a number in each custom object with the ...
-1
votes
1answer
66 views

How to avoid nested loop in the trigger [closed]

We have a trigger if case status got change new support record should get created. but in my case it is creating more than one record, I am thinking it might be because of a nested loop can someone ...
0
votes
1answer
28 views

email templates loop

I have some strings variables: test1 test2 test3 ... Each of them with some text inside I have in my html email template : test1 test2 test3 .. I would like to know how to iterate with : body = ...
0
votes
1answer
26 views

combine variable loop apex

I have a simple question: I have a loop that iterate on an integer i. each loop iteration i becomes i+1 I have another set of variables : x1, x2, x3, x4 etc I would like at each iteration of the ...
0
votes
1answer
54 views

Lead and Account custom duplication check

In the following method: public List<Id> getLeadIds(Lead[] listOfLeads) { List<Id> leadIds = new List<Id>(); for (Lead lead : listOfLeads) { if (lead.Company != null ...
0
votes
1answer
31 views

Concatenate related contact names in a flow

I have a junction called MeetingContactRelation to link attendees to a meeting: Meeting - MeetingContactRelation - Contact I have a hidden rich text field on Meeting and want to store the ...
0
votes
1answer
44 views

AmpScript lookup function: Display data from multiple columns in a data extension?

I'm creating an email to display subscriber's order details. All the data is stored in one spreadsheet/data extension. The columns include OrderID1, OrderType1, OrderID2, OrderType2, OrderID3, ...
0
votes
1answer
84 views

AMPScript For Loop Dynamic Variable

I am trying to get a dynamic variable set inside a script block with AMPScript. Here is what I got: FOR @i = 1 to 5 DO TreatAsContent( Concat( "SET @Test", @i, " = ", 'some value' ) ) NEXT @id ...
0
votes
0answers
23 views

Processing CampaignMember object without hitting governor limits

Campaign is used to create parent campaign which is assigned to each term. Each parent gets set of child campaigns with parentId=null (that's how we distinguish between parent and child campaigns) ...
1
vote
2answers
69 views

How can I create 1500 contacts for my units tests without hitting CPU limit?

I am creating a script that gets run every quarter that checks for any paid status in campaignMember objects that has contactId attached, and update the status to unpaid and create a campaignMember ...
1
vote
0answers
161 views

SSJS - Read a Data Extension after an Rows.Update

i'm now in my firsts baby steps in JavaScript on Salesforce Marketing Cloud. In my script i read one Data Extension with an DataExtension.Init("DE") and a DE.Rows.Retrieve(filter). After this, some ...
2
votes
1answer
205 views

Waiting for results from APEX call in a for loop

I need to load a number of records more than the 2000 default limit for an SOQL query, but I need to wait until all of them are loaded before moving on. To do this, I make a request to get the total ...
-1
votes
2answers
76 views

How to remove list elements without an additional for loop?

I need to remove from the following revenueList list all elements where newRevenueDate is NULL without any additional for loops. List<Revenue__c> revenueWithNoDateList = new List<Revenue__c&...
1
vote
2answers
106 views

How can I efficiently loop through opportunities on a list of accounts?

Currently we have a few nested for loops in our codebase that are doing what is mentioned in the question, but if we data load a large amount of records we run into CPU time errors. I am wanting to ...
0
votes
1answer
41 views

How to Loop through a map that contains multiple object IDs?

Must be really simple but I am struggling with how to loop through this map. Gone through some examples but was unable to figure it out. Question is, how to loop through user IDs from TargetActorMap ...
0
votes
2answers
54 views

Lightning Event in Looping [closed]

I know it's a strange question to ask without context but what would be the implications if I have a lightning component firing an 'COMPONENT' type event every 1 second? I imagine it would be quite ...
2
votes
0answers
99 views

GTL Json data looping

I have a GTL code that loops through my JSON code. In the JSON string i have several order data but in each array there is the same adress information like so: [{ "name":"This is a name", "sku":"8547"...
1
vote
2answers
105 views

Unique Values in Ampscript Loop

Is there a way to do a Loop where it only Loops through Unique values? Customer | Store John | 111 John | 123 John | 111 John | 100 Right now I have a basic loop where it matches on ...
1
vote
2answers
174 views

Are objects from For Loops passed by reference or value?

If I have a for loop that loops through results from a database query, is the single record a reference or copied value? The reason I ask is because I am attempting to update these records, but would ...
0
votes
0answers
67 views

Populate date fields on multiple records using a formula?

So we have a custom object called 'Sessions' (child). Sessions are automatically created via a trigger for a 'Course' (parent). Now depending on the value of the 'Level' field (on the Course) object, ...
0
votes
1answer
93 views

GTL counting Json string

I have set up a GTL and AMP script that looks at my attributes where i passed in a Json string (array). This is the string: `[{"MiddleName":"der","LastName":"Test"},{"MiddleName":"van der","LastName"...
0
votes
2answers
34 views

SOQL Query Causing For Loop to Not Function

pretty simple question that I just can't figure. The first snippet updates a record just fine, but the second snippet does nothing, even though it compiles just fine. Many thanks. Why does this work: ...
2
votes
1answer
50 views

Too many SOQL queries - wanting to store in a map and check

I need to maintain a record for each month up to 10 years away, so 120 records ahead. This might be extended in the future! The code global with sharing class AccountingPeriodCreationService { ...
2
votes
1answer
429 views

Best practice using Schema.SObjectType

Wants to know please, 1) Why using the Schema.SObjectType is better than using a SOQL? 2) If using the Schema.SObjectType inside a for loop is a bad Idea... for example: Id devRecordTypeId = Schema....
0
votes
1answer
228 views

Saving data from HTTP response in a 'for' loop

Background: We're building an app, that will be periodically calling out to external web service to retrieve data in XML which we need to parse and save to Salesforce. So far: We have an Apex Job ...
0
votes
2answers
124 views

Add second element of map (multiple same ID)

I wanted to know how to get the second element of my oppTeamMemberWrapper map knowing that its ID exists in several times in the wrapper map (the ID being the ID of the parent opportunity)
0
votes
1answer
20 views

Trigger - Get all occurence of map in same get

I have a map map like that and I wanted to know if I could get all the occurrences of my key in one and the same list (without making a loop). Would you be able to do that? @future public static ...
0
votes
2answers
25 views

Apex output only showing id how to show all data in list?

I am trying to display data that is being return by an API. On my system.debug I can see the data is there but on displaying on the page it only shows an array of the ids of the list object. This is ...
0
votes
1answer
47 views

How to pass query variable from soql into loop

I am trying to bulkify a callout where I want to pass the recordtype in my loop but I get: Error: Variable does not exist: RecordType If I try public RecordType personAccountRecordType I get ...
0
votes
1answer
94 views

Sum up values(currency) from the list

Decimal totalReceived = 0.00; List<Money_Received__c> moneyReceived = [Select Amount_Received__c,Reservation__r.Total_Recieved__c from Money_Received__c where Id =: reservationId]; for(...
0
votes
2answers
44 views

Is it possible to loop through user input in a visual flow?

So if I have a textbox where the user can input account number (ex. 123,456,789), can I get the flow to separate the input by comma and find those accounts and update them? If so, can someone help me ...
2
votes
2answers
250 views

Nested for loop comparing two different lists and update

In the following nested for loop in getting duplicate id error. I think it's looping more than once and adding records again. Anyone please suggest something to enhance this code to avoid over looping ...
0
votes
1answer
34 views

How to reassign an object to the user with Role 'X'?

We have a few users with Role 'X'. We need to reassign an object to one from these users, if it's created not by one of them. But my loop choose the last one and change owner even if owner is already ...