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 [set]

The tag has no usage guidance.

2
votes
1answer
22 views

Adding null to Set<Id> doesn't return an empty Set

Set<Id> testIds = new Set<Id>(); testIds.add(null); system.debug('testIds are ' + testIds); system.debug('Size of the set is ' + testIds.size()); system.debug('isEmpty result is ' + ...
0
votes
0answers
21 views

Having trouble with a date/time get;set;

UPDATE I made a global string in the controller called temp date composed of the date as yyyy/mm/dd and then used THIS is the get;set; var rather than the one I directly use in the query. When I am ...
-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
25 views

Cover a ApexPages.StandardSetController in a TestClass, help

thank you for your time, right now I'm trying to cover as the title says a standardSetController but I'm having some difficulties, the rest of the code is covered so I don't think i need to put the ...
-3
votes
1answer
26 views

Set contains (Filed name from Map<String, Schema.SObjectField> fieldMap ) not working

I have a below code to check the filed name inside the set to filed name inside the map. Map<String, Schema.SObjectField> fieldMap = Schema.SObjectType.Test__JobApp__c.fields.getMap(); set&...
0
votes
1answer
29 views

How to pass two same lookup records to one set <Address__c> parameter

i have two classes. in the first class account object having two lookup fields like "ship from" and "ship to". but these lookup object is one that is Address__c object. these lookup fields have ...
0
votes
0answers
28 views

How to cover set<Employee__c> parameter in static method

how to cover Set of value parameter in test class. please check below my code public class test { public static Decimal testamount(set<Employee__c>Emp, string state){ ---- ----- ...
0
votes
1answer
18 views

Can rendered attributes handle Set .contains method?

I have a set named "voted" in my controller and I want to use that set on my visualforce to check if the user already voted on the idea. public Set<String> voted = new Set<String>(); I ...
0
votes
1answer
56 views

How to check date field with set of dates?

I have list of dates and I have stored them in a set. List<Account> a=[select id,duedate__c,overduedate__c from account]; Set<Date> sdate=new set<date>(); Set<Date> s1date=new ...
0
votes
2answers
48 views

Error Method does not exist or incorrect signature

Getting the following error at line number 7. Method does not exist or incorrect signature: void add(Auto_Risk_Fill__c) from the type Map List<Auto_Risk_Fill__c> autoValues = new List<...
1
vote
1answer
108 views

Converting Set to List creates duplicates of my Sobjects

I am adding manipulated Accounts to a Set multiple times and update it. It fails due to a Duplicate id in list exception. What should be impossible, because the values are coming from a set. After ...
1
vote
1answer
65 views

Set<sobject> doesn't maintain uniqueness although I am fetching Id field

I am trying to upsert a list of records and I may get duplicates so what I did In loop I am adding records to a set then that set into the list for DML. Now problem is coming when I add a record in ...
0
votes
2answers
32 views

Set class method ContainsAll not working for special character '-' in strings?

Facing a weird issue I have spaces and hyphen in my set of strings and now doing at ContainsAll check but it always returns false. If I remove hyphen - between my strings data then it works? Can ...
0
votes
1answer
63 views

Need to change OwnerId field to Queue's Id if the creator of the record isn't from this Queue

I need to change OwnerId of created record to Queue Id, if the record is created not by User from this Queue. If creator is from this Queue, just leave our OwnerId field unchanged. How can I do that? ...
1
vote
1answer
106 views

Set.contains() not working

My set contains custom JSON elements. When i try to use set.contains() method to check if the set has the JSON element it fails. MY JSON DATA: public uJSON(Id id,String name, Boolean manager,Id ...
0
votes
2answers
273 views

Pass Set to static method

My understanding of static methods is that they hold the data until the end of the transaction, right? So, if I wanted to pull information about a set of ids that would be referenced during a for loop,...
0
votes
3answers
36 views

Filter duplicates from List Query

I am trying to filter the duplicate based on a custom field. Its working fine but it is filtering only one duplicate. if there are 3 records, its showing 2 records. The below is my code. List < ...
0
votes
2answers
259 views

Get Set ID from List in Batch Class

The ws_contact_callout class expects a SET of ids. in the Execute methods I attempt to get it but within the loop but the compiler is complaining. How can/should I get the Set of ids without requery?...
0
votes
1answer
68 views

Get Set and Process in Loop

This line works: Set<Id> ids = (new Map<Id, Contact>([SELECT Id FROM Contact WHERE RecordType.DeveloperName = 'recordTypeName'])).keySet(); This line works: ws_contact.future_callout(...
4
votes
3answers
133 views

Duplicate class objects in a set

I am having 2 instances of a wrapper class holding the same values. Then I add both instances to a Set of that wrapper class and both instances are present in the set. Say this is my code: public ...
1
vote
2answers
55 views

Setter value not arriving in apex class

I have a list that contains a collection of wrapper class instances called tacList. The wrapper class effectively contains a checkbox which relates to a case field and a string. The string is not ...
1
vote
2answers
79 views

How to find Field Sets that are using a Custom Field?

I created a custom field in an object a long time ago and now I want to delete it, so I go to Setup > Object Manager > {OBJECT} > Fields and Relationships, and where the field is, I click the ...
1
vote
1answer
52 views

Attempt to dereference a null object : Static method add Id to set

I have below static method where I am trying to add an Id to a set of Ids. This throws subject line error. Can someone please let me know where i am doing wrong? Apex Method public Id ...
0
votes
2answers
55 views

Collection read only : Unable to add to set

I have to populate a set of Ids with Ids derived from a List<List<sObject>> say searchlist. Below code as I am trying gives me System.Final Exception as Collection is read only and ...
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\...
11
votes
2answers
363 views

Maps keySet is a collection that supports remove() but is otherwise read-only

I've run into an oddity with Sets that reference a Maps keySet. It appears you can remove a value from that Set and it will remove the record from the corresponding Map. Yet if you try and add ...
-2
votes
1answer
400 views

System.NullPointerException: Argument 1 cannot be null infiling set

public class relatedListDynamicReferenceController { public List<SelectOption> selected{get;set;} public List<SelectOption> unselected{get;set;} public List<SelectOption> ...
4
votes
1answer
751 views

How to handle attributes of type “Set” in Lightning?

I am trying to collect record Ids of changed records. Therefor I'm using aura:attribute type="Set". But whenever I add the same id twice, it will be twice in my set. As described in the documentation, ...
4
votes
1answer
292 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<...
10
votes
3answers
997 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
53 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
1answer
534 views

Map keyset order is not same when I iterate on the keyset

My understanding is that map keys are auto ordered and case sensitive. When I printed the map or map.ketSet(), it is as expected. However when I tried iterating over the keySet or try to convert it to ...
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 ...
4
votes
3answers
592 views

Set performance - is using addAll and removeAll more performant than for loops?

I am wondering what is more performant in getting the difference between two sets: Something like this: method(Set<Id> a, Set<Id> b) { Set<Id> result = a; result.addAll(b); ...
2
votes
1answer
88 views

Put common values of two sets within one of them without using loop

This is a logic I am stuck with. I have two sets. One set has about 20k records(Set A). Another one has about 5 records(Set B). Set B is a subset of set A. What I want to do is put the common values ...
0
votes
1answer
65 views

Remove based on duplicated field value, set based on parent field

I have a list of rules that are a detail record for requirements. If any two rules have the same parent I would like to remove one of them from the list (doesn't matter which one). I thought I could ...
2
votes
4answers
3k views

Convert and add list of string to set of ID?

I am tring to add list of string to set of Id . i am trying to avoid one more for loop to again loop and convert using Id.valueOf(). Help me to achieve it. Map<String,Set<String>> ...
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 ...
1
vote
1answer
244 views

Problem extracting values from AggregateResult, results in NULL

I admit that I haven't done too much with the AggregateResult object but I can't figure out how to successfully extract the values to add to a Set. Here's my code: public List<AggregateResult> ...
0
votes
1answer
185 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())...
0
votes
1answer
926 views

Add set of values to map when initialize the map?

Set<String> setNames = new Set<String>{'Jon', 'Quinton', 'Reid'}; I am trying a bit of code below, Map<String, Set<String>> addMap = new Map<string, set<string>>(...
0
votes
1answer
34 views

Help with VF page RemoteAction getting a List into a Set for update on SObject

I have custom VF page styled with JS. The list of Ids is passed from the VF page based on what the user selects. The List is converted to a Set and The Service method should take the incoming Ids ...
-1
votes
1answer
226 views

Assign map <Id,Set<String>> in trigger

I have below code where I need Map<ID,Set<String>>, but I am unable to assign that value and it shows error. Can someone please help me? Apex Code // User - Terr Name Map<Id,String&...
3
votes
1answer
111 views

Duplicate sObjects in Set – intended behavior or bug? (API v39.0)

It looks like duplicate sObjects can coexist in the same set, while duplicate class instances cannot. Is this a bug or the intended behavior? This post and this post discuss a similar issue, but the ...
1
vote
1answer
180 views

Unexpected difference using List<sObject> vs using Set<sObject> [duplicate]

I have sets of objects CustomObjectA, CustomObjectB, CustomObjectC... that I need to pass to a method. I would like to put them in a Map of type Map< String, Set< sObject > >, but when I try, I ...
0
votes
1answer
30 views

Illegal Assignment picklist values in set

I need to get two sets of picklist values as strings however no matter what i do list/set etc i get an illegal assignment the only resolution is to have the sets as lists and as the SObject which ...
0
votes
1answer
165 views

Return True when set 1 contains ANY value from set 2

I have the below trigger trigger OpptypeLogTrig on Opportunity (before insert) { Set<Id> Accountids = new Set<Id>(); Set<id> Oppsid = new Set<Id>(); for(...
1
vote
1answer
156 views

Need clarification on a getter

I have a custom visualforce page and controller extension that is working. There is one getter that I do not understand why it works. I was hoping someone could explain it to me. In the below code I ...
3
votes
1answer
234 views

Use Set in SOSL queries

Currently I am using SOQL query in apex class: for(Account acc: [Select FirstName,LastName,Territory_vod__c,NPI_vod__c from Account where Name In:accountSet ]){ accountSet is set having list of ...
3
votes
1answer
117 views

Create map of User and corresponding List of Accounts

I have an object where exist an Account and user lookup fields. Now records of the object will have always user and Account combination as unique. It means U1 -A1 combination can not exist in multiple ...