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
2answers
33 views

LWC JavaScript: Can't Add a Property to Objects While Looping through an Array of Those Objects

I'm trying to loop through an array of objects and add a property to each that meets certain criteria. Here's the snippet: onRecordEditFormLoad(event) { let tempFieldWrapperArray = this....
0
votes
2answers
21 views

SFDC Flow Loop to add multiple strings to a text area field

I have a nested loop iterating over EVENTWHORELATION (outer) and then into CONTACT (inner). The loop iterates each EventWhoRelationID for a match against a ContactID. I admit going over all contacts ...
1
vote
2answers
59 views

Flow with invocable apex

Apex beginner here so I'm open to any and all suggestions. I'm working on a flow + invocable apex combination to mass reassign records. Basically trying to take variables obtained by the flow and ...
0
votes
0answers
24 views

Loop Variable Accessibility Issue

I have a unit test with this context data: List<Contact> testCon = new List<Contact>(); testCon.add(new Contact(AccountId = '0014000000zoemWAAQ', LastName ='Accounts Payable', ...
0
votes
1answer
33 views

Map<ID, Set<String>> Loop Question

I have a Map<Id,Set<String>> In my code. I have a loop structured as this: for(value : data) { for(String string : Map.get(value) { //Do something } } When I do this ...
0
votes
1answer
43 views

Loop Element not reaching If Condition

Really two different things here. What this is doing is comparing the Email addresses of an external platform (Zuora Billing platform) to email addresses and accounts that already exist within SFDC. ...
1
vote
1answer
86 views

How to Optimize a Nested For Loop and Avoid CPU Limit Errors

I'm been tasked w/ updating another Developer's code that was running up against governor limits (specifically the Apex CPU limit). The code in question is fired via the before update trigger on the ...
0
votes
1answer
19 views

Variable does not exist: error message in the developer console

I am getting error message 'Variable does not exist:' for 3 updateDA. variables. What is the cause? Thank you! else if (Trigger.isUpdate) { for (Account accNew : Trigger.new) { ...
0
votes
0answers
47 views

Flow Loop not processing the last record

I'm building a flow that takes the subscriptions listed on our contract record and creates a record in a custom object called Entitlements. Our contracts may have the same subscription listed more ...
0
votes
0answers
18 views

bulkify a scheduled flow

Currently i am working on a scheduled flow to update the opportunity record whenever a phone no field is there on the associated account record .the scheduled flow is taking the data on campaign ...
0
votes
0answers
24 views

Get unique set of string values from a query

I have a custom object called Asset__c in which there is a lookup field called Site__c which is linked to another custom object called Site__c. This Assets object has more that 20k records. What i ...
0
votes
2answers
42 views

Is there a way to dynamically generate conditions in a loop

I currently have a batch proces which gets an amount of records as a scope. I want to execute some manipulations on these records based on some conditions where only 1 value changes and where the ...
-2
votes
2answers
27 views

How do I test the FOR loop data for this code?

I have written a test class for a class and its coverage is above 75% but I want to increase it and found that a particular for loop is not being covered(written Between ** below). Please help me with ...
0
votes
0answers
32 views

How can I take the values from multi select picklist into another field?

I have a multi select picklist which I need you take the values and put into a child object. The picklist has 100 values. Can't use cross object formula because of char limits. Is there any way to do ...
1
vote
2answers
60 views

How to avoid too many queries in Flows

I have a complex requirement that iterates over 277 records. I have achieved it using scheduled flows. For each of the 277 records, I need to automatically create related records, which I have done ...
0
votes
1answer
41 views

In JS of LWC, line after forEach statement does not execute

I have below Javascript function in lwc apexJobInfoData; @track isBatch; getData({ error, data }) { if (error) { // TODO: handle error } else if (data) { this.jobId = ...
0
votes
0answers
25 views

How to update all actual records when 1 of them is updated?

I have code. But it's a bad practice with query in the for-loop. How to make it better? The point is that I need to update comments in all actual tools when the comment field is changed in one of ...
0
votes
1answer
41 views

How to loop trough subquery and fill fields in array Json object

I have created a custom object to create a json string. I kan loop trough the list to fill in the first level/parent fields. How do I loop trough the subquery and fill the arrays in the json object. ...
3
votes
2answers
1k views

For loop only loops 5 times

I have a vf page that creates 10 dummy Attachments so it can display on the page. When I go to save the attachments I"m looping through the list and removing the bad ones. The problem is it's only ...
1
vote
2answers
57 views

How to loop trough map and get record by field value

I have a map<Id,String> subMap this is the id of a record where the string is a name of a Future_record__c yet to be made after a callout. How do I loop through the subMap and get the ...
0
votes
2answers
40 views

How can I take my SOQL out of the loop?

I have an Id in the String format. I'm trying to convert this string into lookup field if it's the Gear__c Id. How can I take my SOQL out of the loop? trigger SMSTrigger on Message__c (before insert) ...
1
vote
1answer
60 views

How to query multiple object records without using soql within a for loop

I have a Map<String, String> objectNameWithQueryString; objectNameWithQueryString consists of 'ObjectAPIName' as the key and a 'soql query string as the value'. My requirement is to perform ...
0
votes
2answers
257 views

lwc looping till a certain number in html

In lwc for looping through data we have <template for:each={contacts} for:item="val"> </template> If i have a variable where in a number is stored, say for example 4. How do i run the ...
0
votes
2answers
24 views

Removing a key element from a map that exists in Salesforce

I am iterating over the values from a JSON response in an hourly job and putting those values into a map. From there I'd like to compare each map elements key to the Customer__c JobId field. If the ...
3
votes
2answers
2k views

Expressions in for:each index value in LWC? [duplicate]

Currently, I am facing an issue is that I want index starting from value "1" I am using for:each in my code. <template> <lightning-card title="HelloForEach" icon-name="custom:custom14"&...
0
votes
1answer
110 views

How to loop over child objects of master object in batch object

I have a batch process to update Accounts with address info from the Cust_Address__c object. I use a Junc_Account_Address__c object as a junction. How do I loop through the accounts to update the ...
0
votes
0answers
27 views

Need a flow to output number of unique values on a related list

I have a custom object called "Issue" with a related list to another custom object called "Impacted Contacts." There's a join record called "Issue Impacted Contacts." I need to make a flow that will ...
1
vote
1answer
24 views

Inserting dependent objects without using a loop

I have this issue. I have a list of Contracts and I need to create Cases and custom objects called 'Budget' that the Case needs to lookup. The code can be summarized to something like this for(...
0
votes
0answers
33 views

Flow Using more than Object

Trying to build a flow that used GET RECORD to pull a filtered list of Opportunities, and use the AccountIds from these Opportunities to update a list of Accounts. The only way I have achieved that ...
0
votes
1answer
49 views

Values in map overwritten by new ones

I have a Map where I put a String and a Decimal. Both of these fields are updated based on the day of the week. The String field can be converted into a date field since it's populated by the day, ...
1
vote
0answers
63 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
146 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
266 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
41 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
205 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
88 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
1k 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
144 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
223 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
30 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
193 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
52 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
95 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
67 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
201 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
2answers
189 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
79 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
221 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
92 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
145 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 = ...

1
2 3 4 5