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
1answer
23 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
31 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
119 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
184 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
22 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
55 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
25 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
39 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
35 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
68 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
64 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
27 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
26 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
30 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
49 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
35 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
50 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
48 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
64 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
35 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
75 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
33 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
48 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
21 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
37 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
44 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
65 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
48 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
58 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
34 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
30 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
41 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 ...
0
votes
1answer
31 views

How to use field from map query

for (Id sourceObjectId : sObjectsFromDbCloned.keySet()) { SObject sObjectFromDbCloned = sObjectsFromDbCloned.get(sourceObjectId); if (sObjectFromDbCloned.Id != null) { clonedIds.put(...
0
votes
1answer
40 views

Iterating Through a Map<Id, List<Contact>>

This is a concept I am having a bit of trouble understanding. In this particular case I have debugged each piece within it and I can get the values I expect, But I am not able to iterate through them ...
0
votes
1answer
39 views

how to bulk check for opportunity in apex trigger

I have a requirement where I am checking on account trigger (on account update) if any opportunity is having Closed Lost status then changing account description with count of closed lost opp I have ...
0
votes
1answer
36 views

My wrapperlist is not showing up

I trying to create a table to provide metrics on the number of Account and Contact records grouped by state. So each state will have two number of count id. Below is a code for my class and visual ...
0
votes
1answer
47 views

Trying to update records by scheduling an apex class. However, I'm getting CPU Timeout Error with the code below. Am I suppose to use maps?

List<Deal__c> records = [ SELECT Name FROM Deal__c WHERE CloseDate__c < TODAY AND RecordType.Name = 'Franchise' AND (StageName__c != 'Servicing' OR StageName__c != 'Closed Lost') ]...
0
votes
0answers
25 views

Populating a Map<Id,List<Contact>> for a comparison

What I am trying to do here is populate a list from a callout to Looker (BI Tool) then create a Map of Salesforce Account IDs to associated Contact Emails. To do this I created this method: public ...
0
votes
1answer
57 views

Compare map value and set<string> and retain string that doesn't exist in set

I'm iterating over below map. I want to compare map values and set and iterate over the map.values that doesn't exist in set Set<String> articleIds = new Set<String>(); List<...
1
vote
1answer
35 views

first key of map is dissapeared

CSV File contains headers. Full Name - is first column header, Manager Email - last column header. after file input, i create map that contains rowIndex (for VF apex:repeat), 'Header'='Value' (Map) ...