You need to sign in to do that
Don't have an account?
Standard Controller extentions and using getSelected()
Hello... In a StandardController extention I would like to guery fields from records selected in a related list view. So, if the user selects 3 records in the custom object I would like to retrieve their Ids and then perfrom a query based on that List. The List command in red fails with : ' Illegal assignment from LIST:SObject to LIST:SOBJECT:' I've tried different variations of the List with ctl.getSelected but have quite got it right.
How do I structure the List so I can retrieve the selected Ids? Perhaps using List isn't the best way to hold the Ids so I am certainly open for suggestions on how to use 'getSelected'
Regards,
The Extension controller looks like this:
Public class ConAE {
private final Asset_Entitlement__c ae;
ApexPages.StandardSetController ctl = null;
public ConAE(ApexPages.StandardSetController controller) {
if ( ctl == null )
{
ctl = controller;
List<Asset_Entitlement__c> aeId = ctl.getSelected(); //ERROR HERE
System.debug('aeId is: ' +aeId);
List<Asset_Entitlement__c> ae = [select id, Name, Parent_Opty_Aggregate__c, Opty_Aggregate__c from Asset_Entitlement__c where id = :ctl.getSelected()];// This is probably incorrect too
System.debug('*******************m ae is:' + ae);
}
}
For the benefit of others, here's the correct syntax:
List<Asset_Entitlement__c> aei = [select id, Name, Parent_Opty_Aggregate__c, Opty_Aggregate__c from Asset_Entitlement__c where id IN :aeId];
All Answers
You can do like this, no need to use extra variable
public ConAE(ApexPages.StandardSetController controller)
{
List<Asset_Entitlement__c> aeId = controller.getSelected();
List<Asset_Entitlement__c> ae = [select id, Name, Parent_Opty_Aggregate__c, Opty_Aggregate__c from Asset_Entitlement__c where id in aeid];
}
Thank you . However, I still get unexpected token ( aeId ) on this line:
List<Asset_Entitlement__c> ae = [select id, Name, Parent_Opty_Aggregate__c, Opty_Aggregate__c from Asset_Entitlement__c where id in aeId];
I've tried:
IN :aeId];
= aeId];
=:aeId];
Thanks for being patient.
Regards,
For the benefit of others, here's the correct syntax:
List<Asset_Entitlement__c> aei = [select id, Name, Parent_Opty_Aggregate__c, Opty_Aggregate__c from Asset_Entitlement__c where id IN :aeId];
Can I ask a follow-up question on this thread ...
Just what does "getSelected()" do? All the doc says is "Returns the list of sObjects that have been selected.".
Does that meant there's a way to display the data such that certain records are selectable? If so, is that documented anywhere?
I'm trying to use an extention to a standardSetController to allow action to be performed on a selected sub-set of the records on the screen.
What I need to know is how does the user "select" records? there's no check-box next to them or anything. DO they hightlight them?
What is this "action box"? Is there some element I need to put on the page. Right now I'm just displaying one field in a pageblocktable--
<apex:pageBlockTable value="{!opportunities}" var="opp" id="opp_table">
<apex:column headerValue="Name" value="{!opp.name}"/>
</apex:pageBlockTable>
How do you define a checkbox in your view? Does there have to be a checkbox on the SObject?
Hello Ken... The 'Action' was created under Custom Button and links. In our case this checkbox was created as part of a Mass Update button for this custom object. In the button definition, under 'Display Type' you can choose :
Then what do you put in your VG page to reference that button? Any chance you could page a few lines?
Are you displaying the list in the pageblocktable?
It can be just like
List<Asset_Entitlement__c> aei = [select id, Name, Parent_Opty_Aggregate__c, Opty_Aggregate__c from Asset_Entitlement__c where id IN : (List<Asset_Entitlement__c>) controller.getSelected();];