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
lizmijohnlizmijohn 

How to retrieve matching custom object records to opportunity as a related list on click of a button?

Hi,

I have 2 look up fields to  'source' & 'destination' objects and a pick list on Opportunity page. There is a custom object 'Orders' that is again have lookup fields to 'source' & 'destination' objects. 

Opp1 has Source - Dubai and Destination- Sharjah
Order 1 has Source - Dubai and Destination- Sharjah
Order 2 has Source - India and Destination- UAE

There is a button on Opportunity layout by name 'Lookup'. On click of button the 'Orders' related list must be filled with only the matching result. In this case the record will be 'Order 1' because Opp1 has the same source & destination as Order 1.

Please help.

Thanks,
Liz
AmitSahuAmitSahu
You have to create a new visualforce page, inline to the page layout. The standard related list will not give you this option, I guess. So the process will be :

1. Create a inline visualforce page
2. On click of that button or on pageload, get the related record (Order 1) in this case, and show it.

On page load will save a button click and will be a better user experience, but I am not sure about the requirement. You might need the click of the button to show the records.

Hope this helps!!

j
lizmijohnlizmijohn
Hi,

Thanks for your reply. But I have to capture the search result as a related list under Opportunity to do a mass update and sending email to each record.

Is there any workaround for it?

Thanks,
Liz
PeaceMakerPeaceMaker
I dont think it is possible with standard layout. try creating a new Visualforce Page, For the needed result (filter on related list) - you can use a Data table or pageblocktable with the rendered attribute condition to check and filter the records to be displayed in it.

something like this..
                                                                                  (Check for the Source and Desctination here)
<apex:datatable value="{!lstppl}" rendered="{!IF(lstppl != null && lstppl.size>0,True,False)}" var="v" cellpadding="0" cellspacing="0" border="1" width="100%" >
   <apex:facet name="caption"></apex:facet>
    <apex:column headervalue="Parameter Group" style="width:25%;">
    <apex:outputtext value="{!v.Parameter_Group__c}" />
    </apex:column>
</apex:datatable>