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

How to display a Subquery in a visualforce
I need your help. I've a subquery and Im' trying to display it in a visualforce page without any results:
My Class:
public List<SObject> getOpen() { SObject[] Cuenta = [SELECT Name, (Select Subject, WhoId, WhatId, Id, IsTask, ActivityDate, Status, Priority, OwnerId FROM OpenActivities WHERE OwnerID =:USER_ID ORDER BY ActivityDate ) From Account WHERE id=:RECORD_ID]; Actividades = Cuenta.get(0).getSObjects('OpenActivities'); //This is just to verify the Actividades list for(Integer i=0; i<Actividades.size(); i++) { System.debug('********Sobject'+Actividades[i]); } return Actividades; }
In my page I want to display the Subject, WhoId, WhatId, etc.
If I put:
<apex:pageBlock title="Actividades Abiertas" > <apex:dataTable value="{!Open}" var="each" cellpadding="10" border="0" styleClass="list"> <apex:column headerValue="Acción">{!each}</apex:column> </apex:pageBlock>
I have my 5 id's open activities without a problem. But if I put:
<apex:pageBlock title="Actividades Abiertas" > <apex:dataTable value="{!Open}" var="each" cellpadding="10" border="0" styleClass="list"> <apex:column headerValue="Acción">{!each.Subject}</apex:column> </apex:pageBlock>
I've got an error ' SObject.Subject Property Unknown'
In my debug log I have my list with all the data
11:10:0.928|USER_DEBUG|[44,4]|DEBUG|********SobjectOpenActivity:{Status=No iniciada, AccountId=001R000000QAo87IAD, WhatId=001R000000QAo87IAD, Subject=Llamada, WhoId=003R000000MurqIIAR, OwnerId=005400000010CwqAAE, IsTask=true, Id=00TR0000008DY1OMAW, ActivityDate=2010-04-09 00:00:00, Priority=Normal} 11:10:0.931|USER_DEBUG|[44,4]|DEBUG|********SobjectOpenActivity:{Status=No iniciada, AccountId=001R000000QAo87IAD, WhatId=a0BR0000002ppkaMAA, Subject=Enviar Encuesta, WhoId=003R000000MurqIIAR, OwnerId=005400000010CwqAAE, IsTask=true, Id=00TR0000008DiZNMA0, ActivityDate=2010-04-26 00:00:00, Priority=Normal} 11:10:0.933|USER_DEBUG|[44,4]|DEBUG|********SobjectOpenActivity:{Status=No iniciada, AccountId=001R000000QAo87IAD, WhatId=001R000000QAo87IAD, Subject=Generar Reporte, WhoId=003R000000MurqIIAR, OwnerId=005400000010CwqAAE, IsTask=true, Id=00TR0000008DY2nMAG, ActivityDate=2010-04-28 00:00:00, Priority=Normal} 11:10:0.936|USER_DEBUG|[44,4]|DEBUG|********SobjectOpenActivity:{AccountId=001R000000QAo87IAD, WhatId=a0BR0000002ppkaMAA, Subject=Reunión, WhoId=003R000000MurqIIAR, OwnerId=005400000010CwqAAE, IsTask=false, Id=00UR0000004Y5fYMAS, ActivityDate=2010-07-20 00:00:00} 11:10:0.939|USER_DEBUG|[44,4]|DEBUG|********SobjectOpenActivity:{AccountId=001R000000QAo87IAD, WhatId=001R000000QAo87IAD, Subject=Reunion, WhoId=003R000000MurqIIAR, OwnerId=005400000010CwqAAE, IsTask=false, Id=00UR0000004Y5cFMAS, ActivityDate=2010-10-19 00:00:00}
Type "SObject" doesn't have Subject field. Change the signature to
(of course, you need to cast what you need to return)
and VF Page will be
ThomasTT
All Answers
Hi Mayela,
I think to access the Subject you need to access {!each.OpenActivities.Subjct}
Please let me know if this works.
Hi!!
It doesn't work either!!! :smileysad:
Same error: 'SObject.OpenActivities Property Unknown'
Type "SObject" doesn't have Subject field. Change the signature to
(of course, you need to cast what you need to return)
and VF Page will be
ThomasTT
ThomasTT,
THANKS A LOT!!!! You're right with this change my VF works great!!!!!
For all who have the same problem here is the final code:
VF Page:
Class: