We’re rewarding the question askers & reputations are being recalculated! Read more.

Questions tagged [collection]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1
vote
2answers
52 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 ...
-1
votes
1answer
26 views

Loop must iterate over collection: Webinar_Attendees__c

I'm trying to print sub query fields but I got the error like "Loop must iterate over collection: Webinar_Attendees__c". list<Webinar_Attendees__c> re = [SELECT Id,Login__c,Name,...
1
vote
1answer
39 views

Declaring a collection variable without assigning a value

List<sObject> myList; I thought it wasn't possible to declare a collection without assigning a value, but in fact it works. I can 'feel' that it's not a good practice, but I could use ...
5
votes
2answers
275 views

How to choose using Collection<Id> rather than Collection<String>, or the opposite?

During a conference call with a collegue, I saw him using list of Strings while using Ids, referencing to a list of Ids ; I asked him why this choice, he answered 'Ids are strings so it's about the ...
-3
votes
2answers
55 views

How to create a map without duplicate values from a map that contains duplicate values? [closed]

I have a Map which contains the following entries: <1, Developer> <2, Admin> <3, Manager> <4, Admin> <5, Developer> <6, Sales> I need a new Map which shouldn't have the repeating ...
-4
votes
1answer
55 views

How Get ID of the record from Map

I want to add Map id into Method Parameter And required only one I'd not Set Map<Id,fsCore__Transaction_Parameter_Field__c> obj =new Map<Id,fsCore__Transaction_Parameter_Field__c> ([...
0
votes
1answer
111 views

VF Page Error Incorrect parameter type for subscript. Expected Number, received Text [closed]

I'm getting below error when I'm trying to pass values from map to pageblocktable in Visualforce page. ERROR : Incorrect parameter type for subscript. Expected Number, received Text VF PAGE : &...
0
votes
2answers
318 views

How to view size of map in lightning component controller?

component.set("v.filePushJobIds", actionResult.getReturnValue()); var jobsIds = component.get("v.filePushJobIds"); console.log(jobsIds); console.log(jobsIds.size); I see that ...
1
vote
1answer
67 views

Do Maps have an Reliable Relationship between keySet() order and values() order?

Let's say I have a map, for example: Map<SObjectField, SObjectField> valueByKeyMap Assuming neither the Map nor its contents are mutated by other activity in the system, can I rely on these ...
0
votes
1answer
51 views

Would it be better to use Serialized/Deserialize or Lists for generalized Set creation?

As a Salesforce developer, I find I frequently need to extract Sets from List<SObject>, so I'm looking to create a generalized way of creating Sets. The problem is, Salesforce thinks Set<...
1
vote
0answers
107 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
67 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
122 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
28 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 ...
0
votes
1answer
69 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
234 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
38 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
157 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
71 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 ...
1
vote
1answer
589 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(...
-3
votes
1answer
34 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
62 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
139 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
604 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
52 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. ...
3
votes
1answer
417 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> ...
3
votes
4answers
939 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
363 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
1k 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
222 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, ...
12
votes
3answers
2k 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
68 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 ...
3
votes
3answers
219 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
24 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
222 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
332 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
290 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
13k 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
436 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
475 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
1k 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
5k 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
158 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 ...
1
vote
2answers
3k 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
120 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
355 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
1k 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
42 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 ...