0

I have a functionality which uses Apex and VisualForce to create a multi-select picklist of record Names which is an ad-hoc list created by a query. The user can select multiple Names - and an Apex trigger will create a child record to the current record for each of the selections.

I use a VisualForce page to display the whole record. Here is an example of the VF page :

<apex:page standardcontroller="Breach__c" extensions="BreachVFControllerEdit">
    <apex:messages />
    <apex:sectionheader title="{!$ObjectType.Breach__c.label} Edit" subtitle="{!IF(ISNULL(Breach__c.Name), 'New Breach',Breach__c.Name)}"/>
    <apex:form >
        <apex:pageblock mode="edit" title="{!$ObjectType.Breach__c.label} Edit">
            <apex:pageblockbuttons >
                <apex:commandbutton value="Save" action="{!Save}"/>
                <apex:commandbutton value="Cancel" action="{!Cancel}"/>
            </apex:pageblockbuttons>

            <!-- **********   [Record Type : Master ]   **********  -->
            <apex:outputpanel >
                <apex:pageblocksection title="Information" showheader="true" columns="1">
                    <apex:outputfield value="{!Breach__c.Name}"/>
                    <apex:inputfield value="{!Breach__c.Description__c}" required="false"/>
                    <apex:inputfield value="{!Breach__c.Date_of_Breach__c}" required="false"/>

                </apex:pageblocksection>
            </apex:outputpanel>

               <!--BEGINNING OF MULTISELECT PIECE-->
                 <apex:outputpanel id="SubsidiariesDetails2">
                  <apex:pageblocksection title="Products Affected By Breach" columns="1">
                       <apex:inputfield value="{!Breach__c.Vendor_Profile__c}" required="false" >
                       <apex:actionSupport event="onchange" action="{!execute}"             
rerender="SubsidiariesDetails2,Subsidiaries" immediate="false" /> 
                      </apex:inputfield>
                 <apex:pageBlockSectionItem id="selPanel"> 

                <c:MultiselectPicklist leftLabel="Available Products"
                    leftboxatt="{!items}"
                    rightLabel="Selected Products"
                    rightboxatt="{!selectedSubs2}"
                    size="5"
                    width="200px"/>
               <apex:inputfield value="{!Breach__c.Product_Included__c}" rendered="false" required="false"/>                   
             </apex:pageBlockSectionItem> 
          </apex:pageBlockSection>  
          </apex:outputpanel>
<!--END OF MULTISELECT PIECE-->

        </apex:pageblock>
    </apex:form>
</apex:page>

The only part that is relevant to this functionality is the section between <!...BEGINNING OF MULTISELECT PIECE> and <!--END OF MULTISELECT PIECE-->.

What I would like to know is if it is possible to use that section as an embedded Visual Force page within a Page Layout instead of overriding the entire Edit of the object with the whole VisualForce page. Is it possible ? How do I name the extension="BreachVFControllerEdit" at ?

I didn't include the Apex or the VisualForce component ("MultiselectPicklist") used by the page because I didn't want to make this any more confusing than I need but I can do that if needed.

3
  • 2
    You'd need to pull it out into its own page. And you'll have to live with two save buttons.
    – Adrian Larson
    Commented Jun 29, 2017 at 21:00
  • I guess what you're saying is that in order to save the selections made in that section I would need to press the a Save button within that embedded VF section within the Page Layout ?
    – Zoom_v
    Commented Jun 29, 2017 at 21:34
  • 1
    Exactly that, yes.
    – Adrian Larson
    Commented Jun 29, 2017 at 21:35

1 Answer 1

1

If you want to include multi-select portion of the visualforce page, you need to use Standardcontroller of that object whose detail page you will be working.

extensions can be same or you can create new class for extensions. Create reusable piece of code if that can be used for both the extensions (just in case).

You have to juggle between two Save buttons, one at Standard page save and other is Visualforce save button.

0

You must log in to answer this question.

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