Visualforce page:
<apex:page standardController="Opportunity" recordSetVar="opportunities" extensions="selectedSizeWorkaround" showHeader="false" id="muopp">
<apex:form id="muform">
<apex:pageMessage summary="Selected Collection Size: {!mySelectedSize}"
severity="info"
id="mupms"/>
<apex:pageMessage summary="Record Set Size: {!myRecordsSize}"
severity="info"
id="mupmr"/>
<apex:pageBlock title="Opportunity Mass-Update" mode="edit" id="mub1">
<apex:pageMessages />
<apex:pageBlockSection id="mus1">
<apex:inputField value="{!opportunity.stagename}" id="stagename">
<apex:actionSupport event="onchange" rerender="muselectedlist"/>
</apex:inputField>
</apex:pageBlockSection>
<apex:pageBlockButtons location="bottom" id="mubut">
<apex:commandButton value="Save" action="{!save}" id="butsav"/>
<apex:commandButton value="Cancel" action="{!cancel}" id="butcan"/>
</apex:pageBlockButtons>
</apex:pageBlock>
<apex:pageBlock title="Selected Opportunities" id="muselectedlist">
<apex:pageBlockTable value="{!selected}" var="opp" id="mutab">
<apex:column value="{!opp.name}" id="oppname"/>
<apex:column value="{!opp.stagename}" id="oppstage"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Apex Class:
public class selectedSizeWorkaround {
ApexPages.StandardSetController setCon;
public selectedSizeWorkaround(ApexPages.StandardSetController controller) {
setCon = controller;
}
public integer getMySelectedSize() {
return setCon.getSelected().size();
}
public integer getMyRecordsSize() {
return setCon.getRecords().size();
}
}
- Click
- Under Custom Buttons and Links, click New.
- Set the Button Label to Mass Update Stages, and set the Name to MassUpdateStages.
- Set the Display Type to List Button and ensure that Display Checkboxes (for Multi-Record Selection) is checked. Set the Behavior to Display in existing window with sidebar, and set the Content Source to Visualforce Page. Click the name of the page you just created to associate it with this button.
- Click Save.
- Click . Then, click Edit next to Opportunities List View.
- Under Custom Buttons, move the Mass Update Stages button to the Selected Buttons list.
- Click Save.
- Click the Opportunities tab. Select or create a filter that displays some existing opportunities you would like to change.
- You will see checkboxes next to each of the results. Click any number of checkboxes and click the Mass Update Stages button to change the selected stages to any value you wish.
- Click Save
No comments:
Post a Comment