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

Need to avoid inner FOR loop, please suggest [on hold]

I am trying to update data from one object to another Counterparty object to Account Object I have add fields as records of both objects in Metadata type CPRandAccount__mdt Account__c and ...
2
votes
2answers
32 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
71 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
43 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
25 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
56 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
20 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
54 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
60 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
37 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
33 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
34 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
48 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
24 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
23 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
51 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
20 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
42 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
44 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
21 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
65 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
104 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
155 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
67 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
86 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
40 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
44 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
90 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
72 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
59 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
82 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
49 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
342 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
189 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
82 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
19 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
40 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
65 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
33 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
167 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
31 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 ...
0
votes
1answer
12 views

How to update contact fields related to a campaing

I want to update a field on the related contacts of a campaign with a field of the related campaign when the campaing is updated. I can get the contactid trough CampaignMembers but how do I get the ...
0
votes
2answers
30 views

Creating a trigger, that loops through auto number field, checks date and updates specific field to expired

I have an object named EXAM, exams have a unique Autonumber ID that starts from 0 and goes up to 10000. But this auto number is recorded as a TEXT by default. I want to create a loop, that goes in to ...
1
vote
2answers
33 views

Looping through all entries using a Primary_key, Validating and Updating the corresponding field Values

Exam is an object. It contains the following fields - exam_name(String), exam_state(picklist), exam_date(date), expiration_date(date) 'exam_name' is an AutoNumber(string) field (starts from 1 and ...
0
votes
3answers
37 views

Filter duplicates from List Query

I am trying to filter the duplicate based on a custom field. Its working fine but it is filtering only one duplicate. if there are 3 records, its showing 2 records. The below is my code. List < ...
0
votes
1answer
64 views

Generate Dynamic Query without Nested Loop

The requirement is to store object name and field name in the custom object so user can defined object and condition to display survey question. I am developing skeleton code to support the ...