+ Start a Discussion
KlivingstonKlivingston 

Display Related List based on multi pickup list values

Hi everyone

 

I would appreciate if you could help me with this issue and the apex code. I am relativly new to Apex. Here is the scenario:

 

I have two objects Transport and Cases. Within the Cases there is a multi pick list filed (Feedback For) where you can choose the Transports that the feedback is for.  I.e.... EWA, PAR. ...

 

On the Transport page I want to show the Cases that the Feedback For is for that specific transport record.

 

I.e... A case has been created, the EWA and DHL selected from the Feedback For filed. This case record should show under EWA and DHL Transport records but not PAR or others.

 

Thanks in advance.

 

 

KlivingstonKlivingston

here is what I have so far:

 

#Feedback Trigger

trigger TransportFeedbackTrigger on Transport (after insert, after update){
    Map<Id,String> EWAMap = new Map<Id.String>();  
    Map<Id,String> PAR = new Map<Id,String>();
    Map<Id,String> DHL = new Map<Id,String>();
    Map<Id,String> Lewis = new Map<Id,String>();
    for(Cases fb: [Select CaseNumber, Feedback_for__c                         
    From Cases ]                       
    {
        if(String.valueof(fb.Feedback_for__c).equalsIgnoreCase('EWA')){
            EWAMap.put(fb.CaseNumber, fb.Feedback_for__c) 
        }            
        else if(String.valueof(fb.Feedback_for__c).equalsIgnoreCase('PAR')) {
            PAR.put(fb.CaseNumber, fb.Feedback_for__c)
        }
	 else if(String.valueof(fb.Feedback_for__c).equalsIgnoreCase('DHL')) {
            DHL.put(fb.CaseNumber, fb.Feedback_for__c)
        }  
	 else if(String.valueof(fb.Feedback_for__c).equalsIgnoreCase('Lewis')) {
            Lewis.put(fb.CaseNumber, fb.Feedback_for__c)
        }  
    }
}

 

souvik9086souvik9086

The requirement shows like that it needed to be a many to many relationship between the two objects. Because you are saying that case should be displayed in the related list section and also you told that same case can be in more than one transport

I.e... A case has been created, the EWA and DHL selected from the Feedback For filed. This case record should show under EWA and DHL Transport records but not PAR or others.

 

This can be easily manageable if you create a junction object instead of multipicklist. Any special reason for the multipicklist?

KlivingstonKlivingston

Thanks for your reply. Well they need to choose more than one Transport from the Feedback-for field because a case can be related to more than one Transport record.

 

I have never used junction object (JO) before so I am not sure how that would solve my problem. Just to mention again the Cases that will be displaying on Transport page will be base on the value of Feedback-for from the Cases object not the object itself and I'm not sure that is possible with JO ?

 

KlivingstonKlivingston

I have tried Junction Object and it does not do exactly what I am after. So  a help with the code would be really appreciated.