function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Saniya Khan 2Saniya Khan 2 

How to do mapping in apex

Hi Guys,
I have one query in which I have to create puchase order from the opportunity Line item  depending upon the supllier and delivery address.
for example 
Product  supplier delevery address
A             Sam       Home
B              Sam      home
C              John      Home
D               John     Office
then in that case it will create 3 purchase order
PO-1 A and B
PO-2  for C
PO-3  for D
How can we do mapping?

Many thanks,
Saniya
Deepali KulshresthaDeepali Kulshrestha
Hi Saniya,

A map is a collection of key-value pairs where each unique key maps to a single value. Keys and values can be any data type—primitive types, collections, sObjects, user-defined types, and built-in Apex types. The Map methods are all instance methods, that is, they operate on a particular instance of a map. The following are the instance methods for maps.
Please refer to the following links as they may be helpful in solving your query:

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_collections_maps.htm
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_map.htm
https://www.janbasktraining.com/blog/map-in-salesforce/
https://micropyramid.com/blog/how-to-use-map-methods-in-salesforce/
https://www.iterativelogic.com/working-with-apex-code-maps/
http://amitsalesforce.blogspot.com/2016/09/collection-in-salesforce-example-usinrestha

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha