0

I want to display a relation Account>property__c>Booking__c>Order>OrderItem in a visualforce page. I want to nest the objects to represent these as parent>grandchildren> grand grandchildren>etc. I am trying to nest the order in a map but get the error:

Method does not exist or incorrect signature: void put(Id, Order) from the type Map>

I have the following:

   //Property__c id, Booking__c
    Map<Id, Booking__c> bookMap = new Map<Id, Booking__c>([
        SELECT id, name, uidproperty__c 
        FROM Booking__c 
        WHERE uidproperty__c IN :propList
    ]);
    system.debug('bookMap: '+bookMap);
    //Booking id, Order
       Map<Id, Order> ordMap = new Map<Id, Order>([
        SELECT id, Name, booking__c, 
           (SELECT id, PricebookEntry.ProductCode from OrderItems ) 
           FROM Order 
           WHERE booking__c IN :bookingList
    ]);
    system.debug('ordMap: '+ordMap);

I tried the following:

      Map<id,map<id,order>> nestMap = new Map<id,map<id,order>>();
    for(id bkId :bookMap.keySet())  { 
        for(Order ol :ordMap.values())
        {
            system.debug('ol'+ol);
            if(ordMap.values().booking__c== bkId){
                nestMap.put(bkId,ol);
            }
        } 
    }

1 Answer 1

0

According to your map definition, you should put the map of Id and Order in the nestMap.

I am not sure what Id you are referring in the inner map, and dont know why you need so, but it below code should work for you.

Map<Id,Order> orderMap = new Map<Id, Order>();
orderMap.put(someId, ol);
nestMap.put(bkId,orderMap);

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .