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.

-4
votes
1answer
38 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
33 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
45 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
60 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
47 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
25 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
63 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
59 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
54 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
186 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
151 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
60 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
12 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
476 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
17 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
32 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
52 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
93 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
463 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
40 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
325 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
664 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
309 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
934 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
138 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
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
58 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
202 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
22 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
206 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
299 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
221 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
11k 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
379 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
416 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
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
123 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
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
116 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
246 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
776 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 ...
2
votes
1answer
140 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<...
19
votes
1answer
461 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
122 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 ...