0

I'm currently trying to recreate the the functionality of the "Add Product" list button for Opportunity Products. I understand Visualforce pages need to have their controller set to the object they are modifying and this one is supposed to modify the Opportunity_Package__c object. When I go to add the custom list button it all seems okay but this Visualforce page will not show as an available option to use and I'm not sure why.

<apex:page standardController="Opportunity_Package__c" extensions="MetadataPackageEditor">
      <apex:form >
          <span>Opportunity </span>
          <apex:inputField value="{!Opportunity_Package__c.Opp_Package_Rel__c}"/>
          <apex:pageBlock title="Select Package(s)">
          <apex:pageMessages />

          <table style="width:100%;">
              <tbody>
                  <tr>
                      <th style="border-bottom: medium solid black; border-right: medium solid black;">Select </th>
                      <th style="border-bottom: medium solid black; border-right: medium solid black;">Package</th>
                      <th style="border-bottom: medium solid black; border-right: medium solid black;">Products</th>
                      <th style="border-bottom: medium solid black; border-right: medium solid black;">PPU Discount</th>
                      <th style="border-bottom: medium solid black; border-right: medium solid black;">Expiration Date</th>
                  </tr>

                  <apex:repeat value="{!packageMap}" var="oppPackage">
                  <tr>
                      <td style="border-bottom: thin solid black; border-right: thin solid black;"><apex:inputCheckbox /></td>
                      <td style="border-bottom: thin solid black; border-right: thin solid black;"><apex:outputField value="{!packageMap[oppPackage].Name}" /></td>
                      <td style="border-bottom: thin solid black; border-right: thin solid black;"><apex:outputField value="{!packageMap[oppPackage].Products__c}"/></td>
                      <td style="border-bottom: thin solid black; border-right: thin solid black;"><apex:outputField value="{!packageMap[oppPackage].PPU_Discount__c}" /></td>
                      <td style="border-bottom: thin solid black; border-right: thin solid black;"><apex:outputField value="{!packageMap[oppPackage].Expiration_Date__c}"/></td>
                  </tr>
                  </apex:repeat>
              </tbody>
          </table>
          <apex:commandButton value="Add Packages"/>
          <apex:commandButton action="{!cancel}" value="Cancel"/>
          </apex:pageBlock>
      </apex:form>
    </apex:page>
  • Are you trying to override the add product button or recreate with a new custom button? If the former the standard controller must be opportunity product and your additional logic in an extension. – Girbot Feb 23 '15 at 23:17
  • No, I'm trying to mirrored that functionality. The object this is being mirror onto is a custom Junction object named Opportunity_Package__c – Cody Beaner Feb 23 '15 at 23:18
2

For a page to be a valid related list target, you must also use the recordSetVar attribute, which has the effect of changing the page's extensions to use an ApexPages.StandardSetController instead of an ApexPages.StandardController. This is what allows the page to be used on a related list. Without recordSetVar, it can only be used as a custom button or custom link (and, specifically, not a custom list button).

| improve this answer | |
  • Any idea why I might now be getting the following error after only adding the recordSetVar and setting my extension to allow it? Error: Could not resolve the entity from <apex:inputField> value binding '{!Opportunity_Package__c.Opp_Package_Rel__c}'. <apex:inputField> can only be used with SObjects, or objects that are Visualforce field component resolvable. – Cody Beaner Feb 23 '15 at 23:41
  • @CodyBeaner Yes, you'll need to write quite a bit of logic to support the change. I'm not a big fan of recordSetVar myself, but that's the platform's requirements. – sfdcfox Feb 23 '15 at 23:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.