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

How can i order DESC a table filter in contact accountID HELP ME!
i know if i write in my coode this:
SELECT Name, department, phone, gender__c, birthdate FROM contact WHERE AccountID='00136000002JfHw' ORDER BY birthdate desc
this show i want to see but i want to show others contacts asociated with others accounts to.
my code VP
and my controller
i think, i need to change anything in my controller but i dont know.
SELECT Name, department, phone, gender__c, birthdate FROM contact WHERE AccountID='00136000002JfHw' ORDER BY birthdate desc
this show i want to see but i want to show others contacts asociated with others accounts to.
my code VP
<apex:page applyHTMLTag="true" applyBodyTag="false" showHeader="false" renderas="pdf" standardController="Account" extensions="ContactsListController" > <style type="text/css"> <apex:stylesheet value="{!URLFOR($Resource.style)}"/> </style> <html> <body> <div style="float: left; "> <apex:image alt="cargill" title="cargill" url="{!URLFOR($Resource.cargill)}"/> </div> <div style="float: right; "> <br/> <apex:outputText value="Caracas,{0,date, dd/MM/yyy}"> <apex:param value="{!NOW()}" /> </apex:outputText><br/> {! IF($User.isActive, $User.FirstName & ' ' & $User.LastName, 'inactive') } <br/> {! Account.Name } </div> <div style="clear:both;"> </div><br/><br/><br/> <apex:pageBlock > <apex:pageBlockTable value="{!Account.contacts}" var="contact"> <apex:column value="{!contact.Name}"/> <apex:column value="{!contact.Department}"/> <apex:column value="{!contact.Phone}"/> <apex:column value="{!contact.Gender__c}"/> <apex:column value="{!contact.Birthdate}"/> <apex:column > <apex:facet name="header">Age</apex:facet> {!year(today())-year(contact.birthdate)- 1} </apex:column> </apex:pageBlockTable> </apex:pageBlock> </body> </html> </apex:page>
and my controller
public class ContactsListController { private final Account acct; public ContactsListController(ApexPages.StandardController stdController) { this.acct = (Account)stdController.getRecord(); } public List<Contact> getContacts() { List<Contact> results = [SELECT Name, department,phone,gender__c, birthdate FROM contact WHERE account.ID='00136000002JfHw' ORDER BY birthdate desc] ; return results; } }
i think, i need to change anything in my controller but i dont know.
NOTE:- Please pass the AccountID in URL like below :-
https:NA.my.salesforce.com/001q000000IzXEf----- ID should be from your org
Please let us know if this will help you
Thanks
Amit Chaudhary
All Answers
line 23.
<apex:pageBlockTable value="{!Account.contacts}" var="contact">
instead of Account.contacts, replace it with contacts which refers to your controller extension.
thanks
NOTE:- Please pass the AccountID in URL like below :-
https:NA.my.salesforce.com/001q000000IzXEf----- ID should be from your org
Please let us know if this will help you
Thanks
Amit Chaudhary