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
1 answer
20 views

Illegal assignment from list to map

Apex:code public class mapcollection { public static void map_cases() { Map<Id, Case> mc = new map<Id, Case>(); mc=[select id,status,priority,reason,origin from case]; ...
user avatar
  • 13
-1 votes
1 answer
13 views

How to iterate List<Map<String, Object>> in aura component

I want to iterate over List<Map<String, Object>>. I'm not sure how to do it. Below is the response I am getting from apex class to aura controller. [{"label":"Test 1",&...
user avatar
  • 23
0 votes
2 answers
26 views

Retrieve Field Value from Map

I am creating a batch process that looks at all records for the custom object enrollment__c that have a null account_team__c field. That field is a lookup to the account_team__c custom object. The ...
user avatar
  • 329
0 votes
2 answers
39 views

Need Help to Update the two multiple records at the same time with unique value

Hi I am working on the scenario, and need some help from the community, kindly help me out for the below . I have created a below map in my class : - Private Map <Id, string> testMap = new Map &...
user avatar
  • 3
1 vote
1 answer
21 views

Map with empty values are omitted by default

Below is the way I store the keys and values in my map. Map<String, Object> mapNew = new Map<String, Object>(); Object obj = record.get(fieldName) != null ? record.get(fieldName) : null; ...
user avatar
  • 23
-1 votes
2 answers
48 views

JSON Array String into List

Sorry for this noob question but I just want to ask: String stringJSON = '[{"action":"ASSIGN","value":"Router"},{"action":"DISABLE","...
user avatar
-1 votes
0 answers
17 views

Hi Team, I am new to Apex coding, I have created an apex class for insert triggers. Kindly help me to use the map here for bulkify the code [duplicate]

When a contact record is inserted, the corresponding account status and sibling contact records status should update. It is working as per this code. kindly help me to to use maps here trigger ...
user avatar
0 votes
1 answer
23 views

How to map account name with list of phone numbers

I am trying to map the account name with the related phone numbers set<String> phoneNumbers = new set<String>(); Map<String, set<String>> clientNamePhone = new Map<String, ...
user avatar
0 votes
1 answer
53 views

Is there any way to replace nested for loop with map for the following apex trigger?

trigger oppTrigger on Opportunity (after insert,after update) { Set<Id> accIds = new Set<Id>(); Set<Id> oppIds = new Set<Id>(); List<Account> accToAdd = new ...
user avatar
0 votes
2 answers
52 views

attempt to de-reference null object when using maps to build parent-child relationship for visualforce page

Products Products__c Name Label Data Type Sample Data Sample Data 2 Sample Data 3 PDC PDC__c Text ACA ACG TBC PDC Desc PDC_Desc__c Text Tire Size Rim / Wheel Disc Size Type of Toolbox Value Desc ...
user avatar
  • 29
1 vote
2 answers
38 views

How to retrieve the Map's field value from main class when you have function of Map<String, custom_metadata_Object__mdt>

I have a map function, I particularly want to access the function with the npct1_Formal_Letter_Salutation_1__c field from the custom metadata object npct1_FC_Gender__mdt in main class. Below system....
user avatar
0 votes
1 answer
34 views

Given a date, return the ID of the record that is within the Start and End dates

Object Name: Dates__c Fields: Id, Start_date__c (date), End_date__c (date), Week__c (string) Objective: Given a Date e.g '2022-01-07' from an object table that has input as so... Id Start End Week # ...
user avatar
0 votes
1 answer
111 views

How can I pass maps to an Invocable Method?

I have a method in my code that I want to make into an invocable method: // This should be an invocable method with @InvocableMethod private void updateContacts(Map<Id,Contact> newContactMap, ...
user avatar
  • 129
-1 votes
1 answer
32 views

Search items from list and get count [closed]

I have a list of accounts from SOQL as below: List<Account> accList = [Select ID, Name, MyField__c From Account where course__r.status = 'active']; I have added the values of MyField__c from ...
user avatar
  • 15
1 vote
3 answers
89 views

Create a Unique Map from another Complex map structure in salesforce

I have a method like the below public static void formatInput() { Map<string,List<string>> parentMap=new Map<string,List<string>>(); Map<string,List<string>&...
user avatar
0 votes
1 answer
35 views

How can I generate arrays [...] to serialize an object? I want to make a simple JSON serialized

"Hello everyone". I have a couple of days with these json's. I have a json String done, like this: String payload = JSON.serialize( new Map<String, Object> { 'jsonrpc' =...
user avatar
2 votes
1 answer
112 views

Map contains null value for a key but returns false when called from another method

I'm using the following conditional logic in my class if(mapCountry.get(rec.Country__c).Allowed__c != null) The value of mapCountry.get(rec.Country__c).Allowed__c accessed via debug is false. However ...
user avatar
-2 votes
1 answer
117 views

Get for each parent record all child records of a specific object type in a map<parentid, list<childobject>> [closed]

I'm trying to figure out the correct approach to get for each parent record in a list : all the specific sobject child records related to that specific parent record. And I would like to arrange them ...
user avatar
  • 1
0 votes
1 answer
87 views

Add additional key, value pair into map object

I'm trying to write key, value entries to a map object however, it looks like the first key, value pair is being overwritten by the second. Code looks like this: trigger AccountChangeTrigger on ...
user avatar
1 vote
1 answer
22 views

Map from block of xml

I have response xml <?xml version="1.0"?> <xmldata xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" status="SUCCESS"> <recordset name="res"...
user avatar
  • 5
1 vote
1 answer
19 views

Compare List of 2 Objects and output Matched Values

I a using the code below to compare lists of records from 2 different Objects - Resource__c and RateCardItem__c. There is no lookup field on the Resource__c to the RateCardItem. However the ...
user avatar
-3 votes
1 answer
49 views

Populate a Map<String, customObject> when String is the userId and customObject is not related to User Object [closed]

I have a CustomObject and a User Object and both are not related to each other, however there is a field in both the object that stores same values. I have to use that field to compare and create map ...
user avatar
0 votes
0 answers
37 views

Apex - Looping Subquery of Records

In my apex class that handles triggers I query the account along with the related lists of an object. If I use this in execute anonymous I can see the account team records. List<Account> acct = [...
user avatar
  • 329
0 votes
0 answers
29 views

how can i choose one email from all email Map list?

I'm just starting with salesforce and need some help. I need to get one related email from Map email list. I manage to get all emails with this query, but don't know how to get one I needed. Any help ...
user avatar
  • 3
-1 votes
1 answer
48 views

Can I Convert Map<String,sobject> to Map<String,object> [closed]

I have Data in MAP<String,sobject> type map and I wants to put it in Map<String,object> type Map. Please help with this casting.
user avatar
1 vote
1 answer
26 views

Performing an update on record/s that appears in two lists. How to stop the update appearing in both lists (my own old and new lists)

I'm working on a class thats outside the normal trigger set up and used as part of an integration. I'm looking to have two list or maps, one that contains the records data pre update. The second ...
user avatar
-3 votes
1 answer
41 views

Strange behavior with Map use [closed]

I don't understand the behavior of the map. Here is my case : Map<ContractLineItem, Decimal> cliWithNbrMap = data(otherParameters); for( ContractLineItem cli : cliWithNbrMap.keySet()){ ...
user avatar
0 votes
0 answers
36 views

VF google map integration satellite view

I have a task to create a google map with default satellite view. Since lightning:map is not able to do it I thought to use Google API JS to create the LWC component but it looks like I can't do it ...
user avatar
-2 votes
1 answer
32 views

convert list with duplicate id to Map

I am working on an apex which is used to clear Hierarchy field values on User records when a user is deactivated. I am stuck at the last part of code. I have a List with same UserID but with different ...
user avatar
2 votes
1 answer
244 views

Map.get(key) returns null

I am working on a callout that returns info about the Asset object. Based on the response payload, I need to check whether a corresponding asset exists in SFDC or not. If an asset record exists and if ...
user avatar
0 votes
1 answer
72 views

I want to use map instead of 2 for loops

I have a situation where I have a case object which has the Asset Object as its child. I need to check whether a case has an asset with the name 'Test' and then use the created date field of that Test ...
user avatar
1 vote
0 answers
141 views

How to fix System Error : Duplicate Id in list in Batch Apex

I have an error Duplicate Id in list when executing my batch. I looked at different answers on the community but even when trying to implement them, I still can't fix my error. To try to fix the error,...
user avatar
1 vote
1 answer
121 views

Get number of records created per each of last 12 month in apex

I need to query Contacts which were created by the current user per each of the last 12 month and map them by month when they were created. So I need Map<String,Integer> (Map<Month,...
user avatar
0 votes
0 answers
48 views

How to use maps to get list of grand child records for a parent object

I have a parent object (Account), child object(Contract) and a grand child object(contract exceptions). Contract exceptions has master detail relationship with contract. My requirement is to fetch ...
user avatar
-2 votes
2 answers
51 views

because you can't populate a map with lists of lists

trying to populate a map with a list list like this: map<integer , listlist<<sobject>>> mpsosl=[find ' ba' IN all Fields RETURNING contact(name)]; error:Illegal assignment from List&...
user avatar
0 votes
1 answer
122 views

LWC with Leaflet JS >> How to access variables or functions outside of L.geoJson

I'm POC'ing using Leaflet.JS to render maps within a Lightning Community. On initial testing it out it looks good. One aspect I've noted and I'm trying to figure out is that within the JS L.geoJson(...
user avatar
0 votes
3 answers
41 views

Map or String: what do I have to use?

I need to create a method that receives three strings: color, brand and model. Would it be better to put a map that would receive for example ("color", "blue") or directly receive &...
user avatar
  • 123
1 vote
1 answer
55 views

Remove items from map [closed]

I have a map which contains some information about opportunities and sales. AccId Revenue Amount Sales 1 5000 10000 500 2 500 250 250 5 7 10 10 9 25 How can I remove the item 5, because the ...
user avatar
  • 83
1 vote
1 answer
34 views

Combine values from two maps to a third map

The result should display a table of all accounts from a specific user and the aggregateresult of the related opportunities and sales. I create a map (AccList) of all accounts and add the Ids to a ...
user avatar
  • 83
1 vote
1 answer
106 views

Comparing values between maps

I would like to update my exsiting code that uses Lists to instead use maps. Here is what I have: List<object1__c> records1 = new List<object1__c>(); List<object2__c> records2 = new ...
user avatar
  • 125
0 votes
1 answer
87 views

Queueable insert list records from map and keep order

I have Map with Account and Account Id. I want to insert that accounts in Queueable and return list of all ids in order as acount is inserted(Or map, it doesnt really matther). How can i keep order if ...
user avatar
-3 votes
1 answer
40 views

Map getting modified unnecessarily in a for loop

for(AggregateResult sg : siteGeoIds){ if(conNumber == String.valueOf(sg.get('VNContractNumber__c'))){ for(Group gr : groupsToBeAdded){ if(gr.Name.contains(String.valueOf(sg.get(...
user avatar
-1 votes
1 answer
44 views

How to add value into a map which is stored in another map?

Map<Id, SObject> accQuery = new Map<Id, SObject>(); Map<string, Map<Id, SObject>> queriesList = new Map<string, Map<Id, SObject>>(); queriesList.put('select * from ...
user avatar
0 votes
1 answer
164 views

Fill Map<String, List<Id>> from a list

I am trying to build a map<String, List<Id>> where the List<Id> is the list of UserOrGroupId field in the GroupMember Object that has similar Group.DeveloperName values and that I ...
user avatar
0 votes
1 answer
39 views

Create a method which has a List<Account> as parameter that check for Accounts duplicate, must return an Account List

My method is adding the account to the list even tho' there isn't another account with the same name, I want to add just the duplicates to the list, any suggestions? global static List<Account&...
user avatar
-3 votes
1 answer
38 views

How to find unique string from a semicolon separated map keyset?

I have a mapElement which is of type Map<string,List< product2>>. The key part contains semicolon seperated values.It contains values like (catA;catB;catC; , Prod A ) (catD;catE;catA; , ...
user avatar
0 votes
1 answer
56 views

How to filter/split a large list based on specific column values?

I have a list with 50 thousand records. Want to filter those records base on Branch name column values. In the list Branch==>Temp has 3 records and Temp2,Temp3,Temp4==>has respectively 1 record....
user avatar
  • 159
0 votes
1 answer
43 views

Query related Tasks does not work

I need to query all related tasks from a contact (currentRecordId) but my code below shows nothing. What I'm doing wrong? Map<Id, TaskRelation> relatedTasks1 = new Map<Id, TaskRelation>([...
user avatar
  • 431
-3 votes
1 answer
373 views

Create Map from records of 2 List [closed]

I need to create map from 2 lists. One list ids and another list<custom_object__c> objects. But i dont get how to do it? id list is not id from custom_object__c. With on list it easy, but how to ...
user avatar
1 vote
1 answer
44 views

Get object record with unique field from list

I want to remove People__c record from list based on field value I have list of custom object People__c with field Responsible__c which is another object id. I am getting list of id and want to get ...
user avatar

1
2 3 4 5
17