You need to sign in to do that
Don't have an account?

Using GetRecordIds in a VisualForce page
I can use the listViews tag to show the list views in a VF page
Is there any way of getting the records similar to GetRecordIds?
How would I link a VF button to these records?
Is there any way of getting the records similar to GetRecordIds?
How would I link a VF button to these records?
Sounds like I am stuck with with S-controls for this.
GoForceGo wrote:
Thanks Doug.
Sounds like I am stuck with with S-controls for this.
Well... sandboxes will be upgraded to Winter 09 this weekend and then the production upgraded first/second week of October.
It basically says Sobject.name does not exist (for o.name). The getRecords on StandardSetcontroller returns a list of SObjects, not opportunities.
Is there a workaround?
Now I am assuming that you are at the beginning of building something more complicated and just using the standard list controller directly in your page like this does not do what you want?
Message Edited by dchasman on 10-02-2008 03:58 PM
Message Edited by dchasman on 10-02-2008 04:00 PM
Is there anyway of dynamically typecasting the objects? Something like?
I have a written a mini workflow engine inside Salesforce - it essentially let's you describe a sequence of steps, some optional to do some work - it is like an Approval engine, except that Approval engine doesn't have a bunch of functionality I want (Duration of approval task being a key one). I create a task for each step, when the step is completed, I created a task for next step etc...
I want to be able to mass open workflows for any object in the system. The open workflow object will hard code field names for each of the object types in the system...
So here is what I do. So first, I ask the user what object they want to open work flow for (using DescribeGlobal call and create a selectList for it).
Based on the type of object selected, I would use code like above to create a list controller for that object and have the user select it.
Finally I want to use dynamic Apex to set the value of "Open Workflow.FieldName" to be the ID of the objects that I am opening it for...
We have a feature under development called Component Binding lets you go completely dynamic but its going to be a few seasons before you get your hands on that functionality I am sorry to say Component Binding is what you absolutely need if you want to be able to dynamically add components to the server side component tree.
Finally, there is always the option to push more of this to the client/browser - VF can easily produce various dynamic client side representations directly using some of the lower level components like <apex:repeat> and if this is primarily view only data with an action or link of some kind this can be pretty easy to accomplish. At the end of the day you are always free to get as close to the metal of the browser as you want.
When a custom list controller is defined, each of the elements in the list is shown in a table/list (using /dataTable/PageBlockTable/dataList tags).
Is there a standard way to show the "Action" against each item - Check Box, Edit, Del" for each of the rows in the table?
StandardSetController has methods such as getSelected, getListViewOptions and getFilterId. When a custom list controller is defined, how is one supposed to use them? With the listView tag?
It would be very helpful if you could clarify if the following can be accomplished with new list controller or some other mechanism.
I have two objects A and B. I have a junction object called AB which maps n-to-n mapping between A and B.
For a given A object instance , I want to be able to mass create instances of AB object by selecting the B object instances that I want to associate with this A object instance.
Here are the steps in my mind.
- On the detail page of A object with the related AB list, I add a button called "Mass Add B"
- When they click this button, I want to be on a page similar to the list views for B object, where the user can select the records that they want to AB Objects for. The user should be able to select from predefined List Views.
- On this page, I want a button called "Mass Add" which will save these new records to junction object table AB
Is there any functionality in list controllers that accomplishes this?I need to be able to define the VF page for steps 2/3 above:
The trick is in your controller you need to use the getRecords() collection and convert it to your wrappers and then bind the table to the wrapper collection accordingly.
I've been working on a sample that will be up on the wiki/blog soon I hope as I can imagine this to be a somewhat common pattern. It works but there is some trickiness to maintaining a unique collection (only one instance of the AB combo) within the UI which also raises a functional question of whether you want duplicates in the DB or not.
Here's the relevant snippet from my controller, I am binding my apex:pageBlockTable to the caseSelects collection:
Thanks.
I am not clear how this would work.
If pageBlockTable is bound to caseSelects, how is setCon (case collection) used?
Is setCon (case collection) bound to anything in the VF page?
As I mentioned, I really want to use "the list views" - which would imply that I want to be able
to select the record set based on ListViews - I was hoping the use StandardSetController to be able to use
getListViewOptions, getFilterId
One way I can think of is to define a field called "selected" in the object (case) itself instead
of defining a wrapper. Then I can bind SetCon directly to the SObjects.However,forcing such a field doesn't seem like a good way to do it.
And I think you bring up a good issue about duplicates. (I assume your inner loop in the code above trying to do something about duplicates)
Assuming I want unique records, I want to be NOT show the B records for which AB records already exist.
I thought that filtering them out during initiation of SetCon would do it - but it doesn't work. The system shows filtered
record initially, but as soon as a view is picked, it shows all records.
As an example, let's say a list View called "Cases open more than 7 days" has 10 records. However
3 of them already have the "AB" record. When I initiate the setCon, I filter them out. When i
select the list option "Case Open more than 7 days", I again see 10 records!
Message Edited by GoForceGo on 10-19-2008 10:53 PM
However, if I use the Supplier list (without the wrapper), the filters DOES work.
Now it works.
However, doesn't seem like the initial filter that I might apply is respected.
As an example if I restrict the records to those starting with an 'A', the initial list seems to be okay. if I change the list view options to "All", it pulls all the records from the database.
If I use the alternate constructor where I fetch the records first and then pass them to constructor, the refreshes don't happen when I change the list view.
sbase__Supplier__c.Name ASC limit 20 WHERE ((Name LIKE 'A%')) ^ ERROR at Row:1:Column:106 unexpected token: WHERE
Message Edited by GoForceGo on 10-20-2008 09:55 AM
Message Edited by GoForceGo on 10-20-2008 10:01 AM
As for the latter issue, just make sure you have a where clause in the query even if it doesn't have any effect, like where id = null, while we get a resolution to this known issue.
I am now writting another controller to "Mass Edit" existing AB records. If i have 100's of AB records, I want to paginate, If I have 30 records to edit, they all show up on the same page - I though the default was 20 or 25.
I also tried using the Page Size Extension controller does not seem to work.
Message Edited by GoForceGo on 10-20-2008 11:55 AM
Mark
You will have to add code for creating the junction object records.
Then the page is very straightforward. This one doesn't select, but implementing your selection method above in a controller extension will do the trick. The list is driven by the list views set up on the Variable Master tab, renders fast and I could actually let the users edit the variables right in the list if I wanted. Very nice.
Message Edited by MarkL on 11-13-2008 04:14 PM
The first non-rendered pageBlockTable is necessary because it determines the fields available for the displayed wrapper table. Adding a field to the vmlist table makes it available to the wrapper table, essentially functioning as the SOQL query. The getListViewItems method in my controller then filters for only selectable items and displays the result. One strange thing I learned, I initially wanted to display all variables and just disable the checkbox on items already present. Apparently there's some kind of problem disabling checkboxes when displaying things like this, got a server error every time, when the only difference was adding the disabled="true" attribute. So I just filtered instead, which I like better.
And some of the supporting controller.
I want to be able to perform some background action when a user selects a bunch of records and then clicks a button on a list view button(e.g update a checkbox field on all of them).
Before StandardSetController, you would call getRecordIds and use AJAX tool kit. I used to call some server code using sforce.apex.execute.
Is there anyway of doing this with StandardSetController?
Note that when the user clicks the list button, I don't want to go to another VF page - I just want to execute some server code and stay on the same page. StandardSetcontroller works when you have another visual force page in the middle.
No there is no way to do this with the standardsetcontroller today.
One question I have though is how do you indicate status/success/failure of the operation to the user?
Today with Javascript, status/error is a pop-up alert box - it can be a pain if multiple errors are found.
Ideally messages would be shown in-line next to the record.
However, an pop-up page might be another option - similar to what mass edit from list does today.
Andrew,
Appreciate your thoughts on this.
http://community.salesforce.com/sforce/board/message?board.id=Visualforce&message.id=14914
Hi all,
I successfully implement pagination with StandardSetController for custom controller, but
if I have more than 10000 records. I am getting
Too many query locator rows: 10001
I know this is WELL KNOWN ISSUE(for huge data), can you please tell me how to handle this case?
I have post so many time about Apex batching like it is working in APIs, but what about apex lanuage.
Is there any solution to deal with huge data(I mean more than 100000 records) in Apex?
Thanks
Hi all,
I got 10000 records in StandardSetController, How I will get next 10000 records using it? and so on
Thanks
Is it possible to post final code which can process 10000 records.
I am pretty confused after reading the post. Currently I have little over 5000 records that I am able display using javascript pagination. But do not know how to process selected records.
because I am not storing the query results
I am doing -
return Database.query(cntSOQL); //about statement return 5434 contacts
Hello Umpen,
Code as follows:
VF page
Controller code:
public class LeadlistController {
public Boolean hasNext {get; private set;}
public Boolean hasPrevious {get; private set;}
public ApexPages.StandardSetController setCon {
get {
if(setCon == null)
{
String query = 'select name, title, email, phone from lead order by name ASC LIMIT 10000';
setCon = new ApexPages.StandardSetController(Database.getQueryLocator(query));
setCon.setPageSize(100);
setNextPrevious();
}
return setCon;
}
set;
}
public List<Lead> getleads()
{
return (List<Lead>) setCon.getRecords();
}
public PageReference next()
{
if (hasNext)
setCon.next();
setNextPrevious();
return null;
}
public PageReference previous()
{
if (hasPrevious)
setCon.previous();
setNextPrevious();
return null;
}
private void setNextPrevious()
{
if (setCon.getHasNext()) {
hasNext = true;
}
else {
hasNext = false;
}
if (setCon.getHasPrevious()) {
hasPrevious = true;
}
else {
hasPrevious = false;
}
}
}
Do with force!
Thanks
Thanks for the prompt response.
What am I doing wrong? I am getting error at line 27
public class cntlistController { public Boolean hasNext {get; private set;} public Boolean hasPrevious {get; private set;} String Role = 'Primary Contact'; set<Id>eligibleHotels = new Set<Id>(); public ApexPages.StandardSetController setCon { get { if(setCon == null) { for (Account_Group_Relationship__c p:[Select a.Id FROM Account_Group_Relationship__c ar, ar.Merchandising__r a, ar.Substore__r s WHERE ar.Status__c = 'Pending' AND s.Id = :substoreid]) { eligibleHotels.add(p.Property__r.Id); //make list of eligible accounts } String cntSOQL='Select c.Id, c.Name, c.Email, c.Account.Id, c.Account.Name, c.Account.Rating__c, c.Account.special__c, c.Account.Lose__c FROM Contact c WHERE c.email !=null AND c.Role__c INCLUDES (:role) AND c.Opt_out_email__c !=TRUE AND c.Account.ID NOT IN :eligibleHotels ORDER BY c.Account.Name DESC LIMIT :hotellimit '; setCon = new ApexPages.StandardSetController(Database.getQueryLocator(cntSOQL)); setCon.setPageSize(150); setNextPrevious(); } return setCon; } set; } public List<contact> getcnts() { return (List<contact> setCon.getRecords(); }
check missing closing ) bracket
your stament should like
Thanks,
How can I capture selected records from this long list. Do I have to write wrapper class?
I have input checkbox to process selected records?
Appreciate any suggestions.
You should redesign your UI so that a user doesn't have to select from 10,000 records. Create a UI where user first filters down the record. How does a user every go around selecting 5 out of 10,000 records?
I am providing filter through jscript and css. User will be presented with 200 records at a time and select the once that needs processing.
all I need is to know which contact user selected in every page
Appreciate your suggestions
GoForceGo, thank you very much for your solution, it works perfectly! You just saved me countless hours of trial and error!
First of all, thanks GoForceGo for your example.
It's very easy to adapt : I jest replaced your Material__c custom object with mine, displayed Id and Name attributes, and was up and going in minutes with your custom VF page.
When I display the page normally (https://c.cs7.visual.force.com/apex/test), all is fine :
- data is displayed in the table
- the filter list is populated correctly
If I change the way I call the page by passing an ID parameter in the URL, like this (https://c.cs7.visual.force.com/apex/test?id=a08M00000030LkU), it's not OK :
- data is displayed in the table
- the filter list only contains 1 item called 'All', and its id is '000000000000000AAA'
What magic is going on behind the scenes ? This is a NO GO for me ...
Rup
Answering my own post - SOLVED :
PROBLEM : When I call the test page with an id parameter, it seems to think that it is an object detail page and make StandardSetController behave strangely, for filters, as if it did not accept to show any filters for this page.
SOLUTION : I set up a very short VF page accepting id as a param, which then calls my test page passing the id value into another parameter, called something else (cerepid in my case).
When my test page receives the id value in the cerepid parameter, it behaves correctly, displaying the right list of filters.
Have a good day, reader,
Rup
Hello,
I am facing same problem.
mtbclimber,
Could you please explain that where 'SelectedCases' variable is coming from? Please let me know.