Questions tagged [map]

A map is a collection of key-value pairs where each unique key maps to a single value.

Filter by
Sorted by
Tagged with
0
votes
0answers
18 views

map.remove() isn't removing the records from a map [duplicate]

When I update a contact in Salesforce, I want to update the contact's related object's records (Contact Information object) address if it exists else insert a record. I am using the below code but ...
1
vote
1answer
25 views

Map Sort by Object field

I have the following code: @AuraEnabled public static Map<Id,Location__c> getAllStoresInRegion(string currRegion){ LocationService locationService = new LocationService(); Map<Id, ...
-1
votes
0answers
35 views

Key of MAP receiving duplicate values

I am attempting to parse a CSV and load the values into salesforce. It all works perfectly. I then attempted to implement a way to detect duplicates and only insert NEW assets that are in the CSV. ...
0
votes
1answer
22 views

Fetch OpportunityLIneItem along with OpportunityId in Map

Map<Id,List<OpportunityLineItem>> oliList=new Map<Id,List<OpportunityLineItem>>(); for(Opportunity opp:eligibleOpp) { if(opp.opportunitylineitems....
1
vote
3answers
69 views

Why can Map<Id,List<SObject>> be assigned to Map<Id,List<Account>>?

Assigning a sobject map to a specific sobject-type is not possible, i.e Map<Id,SObject> sobjectById = new Map<Id,SObject>(); sobjectById.put(a.Id,a); Map<Id,Account> accountById = (...
0
votes
1answer
35 views

How to clone trigger.newmap when passing into a trigger hanlder [closed]

I was wondering how to clone trigger.newmap or how to still have access to the references associated to it when I want to pass this into a trigger handler.
0
votes
1answer
29 views

How to populate a long text field from map values?

I'm trying to populate a long text field with phones from many contacts, but I don't know how to do it. I want to populate a field called "Authorized Contacts" with all phone numbers returned from a ...
1
vote
1answer
38 views

SObject key of map mutated returns null but serializing returns the value

I am using a SObject as a key and mutating it. When I try to get the map value using the sobject, I get null. However, when i serialize the value, I can see the old value stored. Can anyone clarify ...
0
votes
0answers
17 views

Creating Map by taking Parent Id as key and Child fields as values correnponding to key [duplicate]

I have an sObject(Daily_Revenue__c) which has look-up relationship with opportunity objects. Now, I am trying to create a map which should contains Id of Opportunities as keys and Revenue__c field of ...
1
vote
1answer
166 views

pass Map as parametre from lwc to apex

I try to pass a map from my lwc to my Apex controller after when i click in button every time I get null Attempt to de-reference a null object Do you have suggestions ? where i was wrong if I want ...
1
vote
2answers
56 views

How to loop trough map and get record by field value

I have a map<Id,String> subMap this is the id of a record where the string is a name of a Future_record__c yet to be made after a callout. How do I loop through the subMap and get the ...
0
votes
1answer
46 views

How to fill a map with child Id and Parent record

I am trying to learn about the maps and for this I am trying to do an exercise. For I have the Order and Opportunity objects, the Order object has an Opportunity__c field that relates to Opportunity. ...
0
votes
1answer
25 views

Custom metadata to Map

I have a custom metadata with 6 fields, I want to create a Map with two of those fields which are DeveloperName and NameAnimal__c, Is that possible to do that without a for loop?? Is there any ...
1
vote
1answer
28 views

Aura component get map value using dynamic key

From my understanding of javascript, I should be able to query for map value using key using following code: consts = {'key' : 'value'}; var stringKey = 'key'; var something = consts[stringKey]; ...
2
votes
1answer
79 views

I'm trying to get my map in a certain order based on my list. But the map always return sorted values

Map<String,String> mapvalue = new Map<String,String>(); for (string s : listorder){ mapvalue.put(s, fieldMap.get(s).getDescribe().getLabel()); } Eg;list order is like B,A,C,D Output ...
-2
votes
1answer
43 views

If condition for Values in Map<string,List<string>in apex

I have below snapshot where i just wanted to check if map is having the value 20 in it or not. How i can write if condition for list of string values map<string,List<string>> getmap=new ...
0
votes
1answer
33 views

Filling a map with a query

i'm having big troubles to fill a map with the data of fields of related objects to the one that is declared as value. Map<Id,GPMIR_obj_energyLead__c> mapToMap = new Map<Id,...
0
votes
1answer
27 views

Invalid conversion from runtime type Map<String,SObject> to Map<String,OrgWideEmailAddress>

I am trying to cast the type Map<String, SObject> to Map<String, EmailTemplate>, my code as follows: EmailTemplate emailTemplate = [SELECT Id FROM EmailTemplate LIMIT 1].get(0); SObject ...
0
votes
3answers
33 views

Setting a Map value within a method for a unit test

I still learning here but I am having a bit of trouble understanding this concept. I have a method kind of like this: public static List<Contact> newContacts() { List<Contact> ...
3
votes
1answer
126 views

Generic List to Map?

I have two functions that convert a list of SObjects to a map. They do the same thing except that the SObject is different. How can i combine them to one generic function? private Map<String, ...
4
votes
1answer
192 views

Cannot use deserialized JSON for populating map - why?

I have deserialized some JSON into lists of objects: Map<String, Object> Results = (Map<String, Object>) JSON.deserializeUntyped(response.getBody()); List<Object> ...
0
votes
2answers
23 views

Removing a key element from a map that exists in Salesforce

I am iterating over the values from a JSON response in an hourly job and putting those values into a map. From there I'd like to compare each map elements key to the Customer__c JobId field. If the ...
1
vote
1answer
87 views

Visual Studio Code debugger - how do I see content of object or map?

I've started using Visual Studio Code to run through my debug logs, but am not seeing the content of certain types of variables and am wondering whether I'm just missing something or whether this isn'...
1
vote
1answer
44 views

Binding array nested in a map to a lightning input component not working as expected

I have a component attribute which is as follows: <aura:attribute name="variants" type="Map" default="{names: ['Tom', 'Dick', Harry']}" /> The array in the map is used in lightning input ...
0
votes
1answer
44 views

How to get record from id map

I have a before trigger to compare dates on entry. I want to get a recond based on an id from a map, How do I achieve this. Below is my example with my question on line AAddress__c dummy = ...
1
vote
1answer
45 views

How to create 2 level nested map from SOQL query?

List<QuoteLineItem> childQLIs = [Select id, category__c, Parent_Quote__c, Product2Id, PricebookEntryId, Quantity, Product2Id From QuoteLineItem]; Map<Id,Map<String,List<QuoteLineItem&...
1
vote
1answer
72 views

How to find a Map key (with possible contains text)?

I have custom metadata records in the format: If I store these Key and Values in a Map, how to have a conditional 'contains' check for the auxiliary word: Apartment_1 Use-case: I will need to ...
1
vote
0answers
34 views

Can't save map from Lightning Component back to apex

I'm truly stumped by this one. I have a map of ContentVersion docs. The keys are: "Mine" and "Yours" Depending on who is logged in, you can edit field values in the datatable that has "Mine" in it, ...
1
vote
1answer
17 views

Is it possible to remove of filter keysets by a standard method and only maintain keyset which start with a string

I query over Custom metadata to get 1 record(settings) with custom fields "MdtFieldsAcc" I pass the fields in a map with .getPopulatedFieldsAsMap() and then currently remove 1 keyset (Id). Is there a ...
0
votes
1answer
92 views

Getting null pointer exception on populating map of map data

I am writing trigger to update an order line item of order related to an Account when an invoice line item is inserted corresponding to that order line item. Problem is whenever a loop is iterating ...
0
votes
1answer
32 views

reason: Apex CPU time limit exceeded (refine the codes)

Im struggling to fix this CPU time problem, I have tried to refine my code as good as possible by implementing maps and as can be seen below; public class dailyUpdates2{ /// used for converting ...
0
votes
1answer
51 views

How do I check if a list-value from my Map is empty?

I get this error in case if Opportunity__c has no OpportunityInfo__c. I try to check it with the condition if(opportunitiesMap.get(actualTool.Rent__r.Opportunity__c).OpportunityInfo__r != null), but ...
0
votes
2answers
34 views

How and where can i use map along with list/set collection to get unique output

When I enter united states I need only one language. If I selected wrong language it want to throw an error. Map<String,String> countryMap = new Map<String,String>(); ...
2
votes
1answer
50 views

Placing an array into a Map

I'm placing data from the order sObject into a map and would like to be able to take the data from the orderItem sObject and add it to the end of my map so it can all be sent over in a JSON format. Is ...
0
votes
1answer
75 views

Lightning Maps Not Working in Communities - [Solved]!

The following problem persists when loading a lightning:map in a community page: Refused to frame 'https://maps.a.forceusercontent.com/' because it violates the following Content Security Policy ...
0
votes
1answer
170 views

how to understand JSON.stringify value?

Lets say, I have a map created in aura component controller. I want to send map to apex controler but unfortunately map cannot be serialized by JSON.stringify. My code JSON.stringify([...draftValues....
0
votes
3answers
55 views

Method does not exist or incorrect signature: void add(Object) from the type Set<String>

I am trying to populate this Set (buildingIds) with string values, but I am getting the error: Method does not exist or incorrect signature: void add(Object) from the type Set. I am returning some ...
1
vote
1answer
24 views

Inserting dependent objects without using a loop

I have this issue. I have a list of Contracts and I need to create Cases and custom objects called 'Budget' that the Case needs to lookup. The code can be summarized to something like this for(...
0
votes
1answer
65 views

Mapping two Lists/Sets

I am trying to get my head around mapping two sets (or if this is even the right approach). The objective is to take the name of a custom object (which is currently an email address) and map it to a ...
0
votes
1answer
42 views

How to avoid multiple soql queries?

I am working on something that requires insert, update and delete actions on Account object. I have written the below code but would like to know if there's a better way to do this by using maps ...
0
votes
3answers
78 views

Update map.values() doesn't work

I don't know why my object's field from map doesn't change. Can you help me please? public void changeCommentAfterUpdate(List<OppDesc__c> newOppDesc){ Map<Id, Tool__c> mapToConnect = ...
0
votes
1answer
36 views

Values in map overwritten by new ones

I have a Map where I put a String and a Decimal. Both of these fields are updated based on the day of the week. The String field can be converted into a date field since it's populated by the day, ...
0
votes
0answers
49 views

Fix the logic for proper comparison using a Map

I'm trying to check and change the Client__c value in Mopping__c if the In_date__c has changed in the needed Rent__c. There is a lot of data, therefore Map is used. Structure: if Mopping 1 is related ...
0
votes
1answer
23 views

Invalid type for Map

I have a Map inside a Map where I want to put values of type String (TechDayMonthYear_2__c) and Decimal (AttendanceRate_2__c). But I get 2 errors "Invalid type: tp.AttendanceRate_2__c" and "Invalid ...
0
votes
1answer
16 views

How to get a List Element of a Map

I have a map Map<Id, list<Boolean>> mapOfIdAndListBoolean = new Map<Id, list<Boolean>>(); I think I can get the whole list by using mapOfIdAndListBoolean .get(order.AccountId). ...
0
votes
1answer
27 views

Null Pointer Exception when trying to compare one field to update records

I have a requirement where I need to compare Child object records of one parent and update values based on that. Parent Record -> Contact Child Record 1 -> Driver (has lookup to contact) Child ...
0
votes
1answer
39 views

How to populate a map with inner class variables?

I am trying to reuse a map in my code which is originally populated by a query for account. I am creating another query, which results should also populate the same map. Not sure if that is possible. ...
0
votes
1answer
23 views

Putting values in the Map

I am trying to put some values in the Map for learning purpose but getting some error , i am not sure i am following the correct way or not . public static Map<String,String> monthMap=new ...
0
votes
2answers
54 views

How to iterate over Map with same key, but different values?

I have this map: for(Opportunity opp: [Select Id, AccountId From Opportunity Where Id IN :SetIds]){ mapAcctOpp.put(opp.AccountId, opp.Id); } When I try to iterate over this map like this: ...
0
votes
0answers
35 views

First item in Map returning null when getting key value while iterating through List

I'm building a List<String> with the column header row from a CSV file to iterate through and get the API value from a Map<String,String> that is built from custom metadata. The issue I'm ...

1
2 3 4 5
14