Questions tagged [collection]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
22 views

Collection is Read Only - Map.Remove()

I am building some maps to compare which profiles have access to which fields. In doing this I need to compare the results of a FieldPermissions query against all available fields as there is not a ...
0
votes
1answer
26 views

Dynamically checking the values of a wrapperClass for a validation

I have a wrapper class. public class wrapperClass{ String s; Date d; Integer i; Id id; } There are different operations for which certain fields are required on these wrapper object. Example 1. for ...
1
vote
2answers
40 views

Any limit for map collection size for ReadOnly page

Context Since Lightning component Aura or LWC does not support @ReadOnly mode yet, we have opted for a Visualforce page to export queried data into an Excel and benefit from higher query rows limit. ...
1
vote
2answers
53 views

How to pass a list of string values to a picklist in a flow

I currently pass a list of strings from my apex class to a flow. The list of strings {!cancellationReasonsList} I pass to a choice recource. The choice recource I pass to a picklist. Instead of ending ...
1
vote
1answer
57 views

What exactly does the 'Base Collect Tracking Code' in Personalization Builder refer to?

I've been looking through all the documentation, and I can't seem to identify what the 'Base Collect Tracking Code' is referring to, or why it is now 0 for us. It used to have data in it as far as I ...
0
votes
1answer
45 views

update phone number field on Account obj off of phone number from Lead obj

I'm writing a Queueable Apex, that will run and compare search the Lead last name to the Account name if Lead lastname == Account name && Account phone field is null || blank then update the ...
-1
votes
4answers
94 views

Apex maps usage of keyset()

i have a method in that there is a map Map<String,String> formSubmissionData = new Map<String,String>(); formSubmissionData.put('contact__c',contact.Id); formSubmissionData.put('...
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 ...
-1
votes
1answer
39 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
46 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
285 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
115 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
371 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
274 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
899 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
80 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
163 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
134 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
219 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
31 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
80 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
351 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
39 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
161 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
115 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
907 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
41 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
81 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
180 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
870 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
64 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
532 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
3answers
1k 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
418 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
2k 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
468 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, ...
13
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
72 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
238 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
25 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 :- ...
7
votes
1answer
240 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
347 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
398 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())...
16
votes
2answers
19k 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
583 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
568 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
2k 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, ...