I'm currently trying to make a system for selecting multiple objects and connecting them to a related list within Opportunities.
The last piece of the puzzle for me is getting the ID of the opportunity.
Since this will be a list button I can't treat it like a scenario and just use {!JunctionObject.Opportunity}
as that returns as a null entity.
Alternatively if anyone has any ideas on how to more efficiently do this it would be greatly appreciated.
APEX values
Custom Object: Package__c
Junction Object: Opportunity_Package__c
Junction Objects reference to the Opportunity: Opp_Package_Rel__c
Visualforce Code
<apex:page standardController="Opportunity_Package__c" extensions="MetadataPackageEditor" recordSetVar="Opportunity_Package__c" sidebar="false" showHeader="false">
<apex:form >
<apex:pageBlock title="Select Package(s)">
<apex:pageMessages />
<apex:pageBlockTable value="{!packages}" var="o" id="table">
<apex:column >
<apex:inputCheckbox value="{!o.selected}"/>
</apex:column>
<apex:column value="{!o.pack.Name}"/>
<apex:column value="{!o.pack.Products__c}"/>
<apex:column value="{!o.pack.PPU_Discount__c}"/>
</apex:pageBlockTable>
<apex:commandButton value="Add Packages"/>
<apex:commandButton action="{!cancel}" value="Cancel"/>
</apex:pageBlock>
</apex:form>
</apex:page>