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
1
vote
1answer
50 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
50 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
39 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
23 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
25 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
73 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
34 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
31 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
124 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
189 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
64 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
30 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
42 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
39 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
71 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
73 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
29 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
36 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
50 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
101 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
53 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
39 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
77 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
35 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
15 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
46 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 ...
0
votes
1answer
16 views

Adding values to map in apex inside for each

Map<string,string> salesPerCloser {get; set;} AggregateResult[] closerResults = [SELECT Count(Id), Closer__c from opportunity where ReportRegion__c = 'Brasil' AND CreatedDate =LAST_N_DAYS:7 ...
-1
votes
1answer
66 views

How to avoid duplicates in Map and make the comparison correct?

I have a code to compare then values from list and from map. But I'm getting duplicates in my map and only one map value in the loop later. How can I fix it? List<Tool__c> tools = [SELECT Id, ...
0
votes
2answers
63 views

How can I assert that a map has the values needed?

if anyone could help; I'd appreciate some guidance on a test class I am working on. I am new to Apex and I am trying to test a class that uses a map which is the only piece of code I need testing for. ...
-1
votes
1answer
40 views

calculate the total of a variable based on another variable in JS controller lightning

finalMap=[{"key":"OTC","subprocessName":"CXO","weightage":50}, {"key":"OTC","subprocessName":"Order Management","weightage":50}, {"key":"RTR","subprocessName":"Fixed Asset Accounting","weightage":20}, ...
0
votes
2answers
74 views

Is It A Best Practice To Pass Empty Map Purposely?

Here's the scenario: I've two different classes (say ClassA and ClassB) which will be calling a Static method (say meth1) of ClassC. meth1 has three arguments: List<String> lstStr, Boolean ...
1
vote
1answer
52 views

After Update Trigger and wrong values

I have a Trigger and Trigger Helper. Opportunity is a parent for CompanyOrder__c. One Opportunity can have many CompanyOrder__c records with uncrossed Start- and End Dates. CompanyOrder__c is a ...
1
vote
2answers
38 views

count the ocurances of a value in a list at js controller lightning

Below is my list, and i would like to count the string and keep it in map count==>["Vendor Master","Vendor Master","Customer Master","Customer Master","Customer Master","Customer Master","Material ...
0
votes
1answer
36 views

Reference field in a map of sObjects

I have a map that I need to reference the create date of an sObject that is part of a map. The map is: global Map<String,List<wbsendit__Campaign_Activity__c>> ...
0
votes
1answer
42 views

For loop conditional statement for if a List<Contact> contains an element

I have some code like this. While the conditionals I have are working fine what I cannot check for is if Contact lCon is NOT contained in the sfdcList. I have been trying to find a way to set up a Set ...

1 2 3 4 5 13