Posts

Showing posts with the label Map

Salesforce Fact #818 | Simplified exists check in Map with null coalesecing

Image
Suppose, we want to check if a key does not exist in map or if the corresponding value is null, then it needs to be updated with the new value.  With the new null coalescing operator, the exists check in map can be simplified. Attached is the screenshot.

Salesforce Fact #817 | Map put() method return

Image
The put() method of Map class returns null if it's a new key-value pair which is added. However, if the key was already existing, then put() method returns the old value. This might be helpful when we want to know the old value while replacing the value corresponding to a key. Reference:  https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_map.htm#apex_System_Map_put Attached is the screenshot.

Salesforce Fact #811 | Careful with map with null value in VF page

Image
We need to be careful while accessing map in VF page. If any of the value in the map needs to be null, we should use '' instead of NULL, else it will throw the error: Map key <corresponding key> not found in map. Attached are the screenshots.

Salesforce Fact #780 | lightning map of selected record in screen flow datatable

Image
We use mapMarkers in LWC to show the map for an address. We can render the address map for the address of a selected record in screen flow datatable using a LWC. In this example, we are rendering the map for the shipping address of the selected account record considering the ShippingLatitude and ShippingLongitude values. Attached are the screenshots.

Salesforce Fact #578 | putAll() method in map

Image
There is a method named putAll() in Map Class in Apex. It has two variations. Suppose, we already have a number of sobject records in the map. Now if we want to add further sobject records from the another list of records, we can use the putAll() method instead of iterating over the sobject list. Reference:  https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_map.htm#apex_System_Map_putAll Attached is the screenshot.