- Home
- Technical Library
- Boards
- Cookbook
- Code Share
- Blogs
- Partners
-
More
-
Services
- Training & Certification
- Support
-
Galleries
- Force.com Sites Gallery
- Chatter Challenge Entries
-
Other Web Sites
- Salesforce.com
- Database.com
- AppExchange
- CRM Community
-
Discussions
- Announcements
- General Development
- Schema Development
- New to Cloud Development
- Apex Code Development
- Visualforce Development
- Formulas & Validation Rules Discussion
- Security
- Mobile
- Force.com Sites
- Chatter Development
- Java Development
- .NET Development
- Perl, PHP, Python & Ruby Development
- Adobe Flash Builder for Force.com
- Desktop Integration
- REST API Integration
- Streaming API
- Visual Workflow
- Apple, Mac and OS X
- VB and Office Development
- Excel Connector
- AJAX Toolkit & S-controls
- Force.com Builder & Native Apps
- AppExchange Directory & Packaging
- Force.com Labs Projects
- Open Source
- Site.com
- Jobs Board - Administrators
- Jobs Board - Developers
- Force.com Discussion Boards
- :
- Developer Boards for Force.com and Database.com
- :
- General Development
- :
- Passing selected record ids to Apex controller fro...
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Passing selected record ids to Apex controller from List View
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
08-15-2011 12:53 PM
I'm looking for an alternative to passing selected records from a List View via the URL. Here is how I'm currently doing it, but I'm running into IE URL limits when more than 100 records are selected. This is a custom List view button executing JavaScript.
var ids = {!GETRECORDIDS( $ObjectType.Account )};
if(ids.length < 1 ) {
alert('Please select at least one Account.')
}
else {
// window.open('/apex/Quick_Email?rec='+ids.join(',')
window.location='/apex/Quick_Email?rec='+ids.join(
}
What other methods could I implement?
Solved! Go to Solution.
Re: Passing selected record ids to Apex controller from List View
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
08-16-2011 05:15 AM
You could create a custom list view button that points to a visual force page that uses the standard list controller and uses a custom controller extension to do the actions you want. For example:
VF Page:
<apex:page
standardController="Account"
recordSetVar="accounts"
extensions="quickEmailController">
<apex:form >
<apex:pageBlock >
<apex:pageBlockTable value="{!selected}" var="account">
<apex:column value="{!account.name}"/>
</apex:pageBlockTable>
<apex:pageBlockButtons location="bottom">
<apex:commandButton value="Do Something" action="{!doSomething}"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
Extension controller:
public class quickEmailController{
ApexPages.StandardSetController setCon;
public quickEmailController(ApexPages.StandardSetControll er controller)
{
setCon = controller;
}
public pageReference doSomething()
{
// do something with the selected records
for ( Account acc : (Account[])setCon.getSelected() )
{
System.debug('Account name = ' + acc.Name);
}
return null;
}
}
Re: Passing selected record ids to Apex controller from List View
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
08-22-2011 01:01 PM
Thanks tedward. this worked great. The StandardSetController did the trick.
Re: Passing selected record ids to Apex controller from List View
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
08-23-2011 03:01 AM
Is it possible to use this technique without a Custom Button?
I would like to call a visualforce page like the one shown above with a set of records from another Visualforce Page with own Apex Controller:
public with sharing class myController {
list<Account> Accounts;
public PageReference CallOtherVisualforcePageWithListOfAccounts{
ApexPages.PageReference myRef = Page.MyPage;
// Pass Accounts to myRef !?!
}
}
is there a way to accomplish that?

