Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [collection]

The tag has no usage guidance.

1
vote
0answers
12 views

Extract URL of the image from Rich Text field

I have a Rich Text Area field named 'ItemDescription__c' that belongs to a custom object 'Item__c'. Is there any way to extract the image's URL in that text area (an HTML code), and put it in a ...
-1
votes
1answer
61 views

Assigning a Set<String> to a string value

I tried separating the trigger and class, but now I am unable to populate the account field, ProductsOwned__C with the set of string elements, mapTemp. I am looking to make edits on the asset(s), take ...
-1
votes
1answer
24 views

How salesforce compares on sObject with another

We know that "Set" is a collection of unique records. If I am creating a set of SObjects, on what basis Salesforce identifies Uniqueness of the entries in the Set?
0
votes
1answer
39 views

Convert List<Id> into Map<Id,sObject>

I have a list of Account Ids with me. I want to convert it into Map. Is it possible to do that without using SOQL in loop to retrieve the Account object per ID? I need this to add it to my trigger ...
0
votes
0answers
25 views

Processing & writing bulkified validation using more than 50k records

I have two fields in my Opportunity object: Phone_1__c & Phone_2__c. Now I have to check to check the whole Org, if there are any opportunities made earlier using any of these two numbers. (Org ...
1
vote
1answer
47 views

Optimize code by reducing many If-else Conditions?

If-else code which I have written. I want to optimize it. (Using maybe Collection). Can someone show me how to do it? if(form.first_name.value == '' && form.last_name.value == '' &&...
1
vote
2answers
167 views

Exception not being caught; System.FinalException: Cannot modify a collection while it is being iterated

Why is this Exception not being caught? I read that System.LimitException is not caught but didn't see anywhere about System.FinalException. Non-Working Code @AuraEnabled public static List<...
0
votes
1answer
34 views

How to merge these two map into one map?

Set<ID> folderIDS = new Set<ID>(); Map<ID,Custom_Folder__c> foldersToUpdate1 = new Map<ID,Custom_Folder__c>(); Map<ID,Custom_Folder__c> foldersToUpdate2 = new Map<ID,...
0
votes
2answers
147 views

Basic Map And I am Stuck in FOR Loop [duplicate]

Here is my Map Map<id,List<Custom_Report_2__c>> mapreports= new Map<id,List<Custom_Report_2__c> >(); for( Custom_Report_2__c cr:cr1){ mapreports.put(cr....
1
vote
1answer
55 views

How to keep displaying set of fields on visualforce with “Add a new item” action again and again

I have a requirement where I have to display fields on visualforce page and then whatever user enters into those fields, fetch them and create a record out of it. I am able to do that one time but I ...
0
votes
0answers
11 views

Live agent API returning data always in ASC order

We are adding list for search result while hitting the live agent API call. This is returning always data in ascending order. Is their any way by which we can define the order for data collection ...
1
vote
1answer
430 views

how to get value from map when wrapper class is the key

I have a wrapper class of picklist values and labels. I am creating a map with picklistValues and List as key and value types. Now, I am getting an error won this line -- objResults.get(...
0
votes
0answers
15 views

Salesforce Flow: transform a coma separated list to a collection

I have a case when multiple values are submitted via Web-to-Case form in a single text field. The task is to create as many lookup relationships from the list as values listed. Before going APEX I ...
-3
votes
1answer
31 views

Why are these collections not equal?

I am currently working on the list concepts of apex and working on this piece of code: List<Integer> ages = New List<Integer>(); ages.add(10); ages.add(20); List<Integer> one = New ...
0
votes
1answer
50 views

Is there any documentation evidence that order of Map keyset converted to List is preserved?

When we execute a code Map<String, String> tm = new Map<String, String>{ 'Monday'=>'\u041f\u043e\u043d\u0435\u0434\u0456\u043b\u043e\u043a', 'Tuesday'=>'\u0412\u0456\u0432\u0442\...
1
vote
1answer
84 views

How to build and serialize

Keith C's answer builds the following "config" output: config: {option1: {isActive: true, isRequired: true}, option2: {isActive: true, isRequired: true} } by looping ...
1
vote
1answer
386 views

Facing “common.apex.runtime.impl.ScalarList@a1324f1f”

I have a child object to contact called"ObjectA".I have a discipline field(text) in the child object and I have the same field in Contact too.Now If I insert 4 child records with different contact ids,...
0
votes
2answers
35 views

Looping Collection doesn't show same order they have

I created a collection (list, set) for Decimal Values. Following are the collection values and their corresponding debugs from debug log I added values to collection and following is the debug. ...
2
votes
1answer
268 views

Flow and InvocableMethod Simple Question

How would I create an array of the values from the flow and pass them into the APEX @InvocableMethod? My method is taking in a list of Strings: @InvocableMethod public static List<String> ...
2
votes
4answers
581 views

Apex equivalent to associative array?

I have the following list definition in my Apex controller: List<Object> mylist = new List<Object>(); And I would like to do something like: mylist.add({ key : objKey, label : ...
4
votes
1answer
293 views

Generic parameter not accepted for sets?

While working on some code for a utility method to remove values from a List, I wrote this method signature, which accepts a List<Object>: public static List<sObject> Exclude(List<...
1
vote
2answers
862 views

Get Unique keys map and Repeated keys map

Trying to form a two maps. One should contain only unique key and its values and another should have repeated keys and its values. Name Position User1 Developer User2 Designer User3 ...
2
votes
2answers
118 views

Retrieving results from a map

I'm trying to work with and understand maps. I have the following map and I don't know how to retrieve one of the results from it, can some one explain what I'm doing wrong? Map<String, ...
10
votes
3answers
1k views

Why Set<Sobject> doesn't support DML operation

As we know that set<Sobject> and list<Sobject> are collection type. So basic question I do have why Set doesn't support DML operation ? We can perform DML on List<Sobject> but why ...
0
votes
3answers
54 views

set to string conversion

Set<ID> objIDs = new Set<ID>(); //objIDs is used to store the user Id's i have two id in ObjIDs, for example: 0054E000001jEoUQAU, 0054E000001lC07QAE. How to query the email address ...
2
votes
3answers
194 views

How to Create a Read-Only Collection? [closed]

I want to create a collection (List or Set) which can behave like Trigger.New context. Means If we use the collection out side of it's class, we should not be able to add any element in this ...
0
votes
1answer
21 views

What is the Correct collection class structure to hold SOQL subquery results?

I've got a scenario where a status field on the parent object needs to be updated to reflect the status of the most recently created child object. To solve this, I've done a SOQL with a subquery :- ...
6
votes
1answer
201 views

Doesn't Set<T> collection implement Iterable<T> interface? [duplicate]

I am trying to join String elements of Set with semicolon. Set<String> elements = new Set<String>{ 'foo', 'bar' }; System.debug(String.join(elements, ';')); getting the ...
0
votes
1answer
286 views

List<string> how much values/Size can it store?

I am Mapping my XML -> String xml; total characters stored into the above string. which needs for iteration of 100's of related records, now I am into a list string -> LIST<STRING> ...
0
votes
1answer
188 views

any shortcut to get set<String> from map<Id,Set<String>> ?

Map<String,Set<String>> st= new Map<String,Set<String>>(); st.put('one',new Set<String>{'1','2'}); Set<string> ss = new Set<String>(); ss.addAll(st.values())...
15
votes
2answers
10k views

List.contains() method in Salesforce

Is there any specific reason why salesforce did not provide list.contains() method. Edit 1: The below methods are added to List class and are available after Spring 18 release to Sandboxes and ...
0
votes
1answer
366 views

Making multiselect picklist value of a record to Map as Key value

In Product I have a multiselect picklist called Zonelist. I just need to have the Zonelist value in a Map collection. For example: Product Name - HP Monitor Zonelist - Zone1; Zone2; Zone3; How can ...
4
votes
1answer
392 views

Pass Case Ids collection to visual workflow from Case List View Custom Button and update cases taking from input screen

Requirement From Case list View, user will choose one or more cases and will click on "Update Due Date" button, where it will show a screen to choose the "Due Date". Due Date screen And finally ...
0
votes
1answer
29 views

Map Clarification

I have declare the collections in trigger code: Set<String> markets = new Set<String>(); Map<string, Map<Date,Holiday__c>> holidays = new Map<string, Map<Date,Holiday__c&...
2
votes
0answers
994 views

Removing duplicates from a SObject Collection in Visual Flows

I am trying to tackle creating multi-touch campaign attribution using visual workflows and am running into a particular use case. To look at all of the Campaigns that are related to the Opportunity, ...
1
vote
1answer
3k views

Compile Error: Loop must iterate over a collection type: Map<Id,List<Event>>

In the code below, I get an error on the bolded line. Says Loop must iterate over a collection type: Map> Any idea how to troubleshoot? Map<Id, List<Event>> events = new Map<Id, List&...
1
vote
1answer
113 views

Not sure why but apex:repeat returning Previous rows of the List

I have a Custom object Quote_Bundle_Product__c and Bundle__c and Product_Quantity__c scenario is : i have developed one visualforce page and that has functionality like user will select ...
0
votes
2answers
2k views

Sorting a List<Asset> by a date

I have fetched assets sorted by date using SOQL query. When I do for(Asset a:lstAsset) and add a to a list, the sort order from the SOQL query is lost. I want the sort order to be retained. Is there ...
0
votes
2answers
103 views

Converting list to map have improper output

Tring to convert List <MBT_SFFB__Facebook_Page__c> to Map<String,MBT_SFFB__Facebook_Page__c> These are the fields in Object :- MBT_SFFB__Facebook_Page__c Select ID,...
0
votes
0answers
212 views

Two different object with same API name, one is part of managed package. Getting collection store error

I have installed a managed package on my org. That managed package has an object with same API name as one of my custom objects. I have a trigger on my custom object where I query my object and assign ...
0
votes
1answer
688 views

How to compare two Different Object Values in Trigger?

I have one Object called "BillingEvent" It has 4 fields. Ordernumber_c, vinnumber__c, CenterExitDate__c, MADCDate__c I have another Object called "Vehicle".It has 6 fields. Ordernumber_c,...
0
votes
1answer
41 views

How to reduce time taken to insert 40000+ records in salesforce using trigger

i am inserting 40000+ records one time in my organization. suppose as per my requirement 19543 record is satisfied to my condition. but 1 to 19542 records are cross checked(unsatisfied ) in my ...
2
votes
1answer
134 views

Is there a better way to order my collection?

I'm trying to display a chronological list of CaseHistory records to display case edits. I have the following code: public Map<CaseHistory,String> getHelpdeskHistory() { List<...
18
votes
1answer
400 views

Is there a specific reason why we can't upcast Sets?

As most stories here begin, I was writing some code for a project that I was working on, and stumbled across an oddity when writing some unit tests. I was testing a method that has a Set<sObject>...
1
vote
1answer
115 views

SOQL for a collection

Is it possible to do a "SOQL for loops" for a collection? I want to know the number of Assets for each AccountID. At first time I created a set that contains the AccountID and I used the SOQL for ...
7
votes
1answer
121 views

iterator() on a set. Reason for it not being in the Apex Doc?

Although not documented as a set method, iterator() seems to work just fine on sets: set<String> strings = new set<String> {'a','b'}; system.debug(LoggingLevel.INFO,'next() on set ='+...
7
votes
1answer
13k views

Convert a Map Values to a List of values

How to convert Map to List, here is what I have tried but getting the error: List<Product2> productList = new List<Product2>(); productList.addAll(mapProducts.values()); Error: > ...
-3
votes
2answers
2k views

When should I use Maps and when should I use Lists in Apex? [closed]

I am bit up confused while selecting from Maps and List whilst working with Apex Triggers, can anyone please explain?
1
vote
1answer
183 views

How to compare values in Excel file before uploading?

Inserting excel file using apex, I have 4 columns in file,Column-1 (Name) can contain duplicate values. I want to perform check if column-1 has same values (for example A) and column-2(codes) has ...
-4
votes
1answer
1k views

Convert list<list<string>> to list<sobject>

I have a output JSON which has object rows in a variable called values. Ex: values=((01uo00000030BpcAAE, 01to0000001pRBx, 913840, test1, 100), (01uo00000030BphAAE, 01to0000001pRBx, 9137, ...