You need to sign in to do that
Don't have an account?
Thomas Reinman 16
Help with SOQL Query On Polymorphic Field (WhatId - Task)
I'm trying to query tasks related to opportunity, provided the context that the user is on the opportunity record. This query will grab that Opportunity ID and display the related tasks in a visualforce page on the layout.
Before you ask what the purpose is, this SOQL query doesn't include all of the filters on Tasks yet; first I just need to get it working for any related tasks.
The apex class is:
Visualforce:
Any thoughts on why this query isn't returning any records?
Thanks
Before you ask what the purpose is, this SOQL query doesn't include all of the filters on Tasks yet; first I just need to get it working for any related tasks.
The apex class is:
public class discoQuery{ //VARIABLES public Opportunity opp {get; set;} ApexPages.StandardController sController; public Map<ID,Task> tMap {get; set;} //CONSTRUCTOR public discoQuery(ApexPages.StandardController controller){ sController = controller; opp = (Opportunity)controller.getRecord(); } public List<Task> tList{ get{ if(tMap == null){ tMap = new Map<ID, Task>([SELECT Id, Subject, Activity_Type__c, Outcome__c, Status, OwnerId FROM Task WHERE What.Type IN ('Opportunity') AND WhatId =: ([SELECT Id FROM Opportunity WHERE Id =: opp.Id]) AND IsDeleted = FALSE ORDER BY CreatedDate LIMIT 1000 ALL ROWS]); } return tMap.values(); } } }
Visualforce:
<apex:page standardController="Opportunity" extensions="discoQuery" lightningStylesheets="true"> <apex:form > <apex:pageBlock > <apex:pageBlockTable value="{!tList}" var="t"> <apex:outputField value="{!t.Subject}"/> <apex:outputField value="{!t.Activity_Type__c}"/> <apex:outputField value="{!t.Status}"/> <apex:outputField value="{!t.Outcome__c}"/> <apex:outputField value="{!t.OwnerId}"/> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page>
Any thoughts on why this query isn't returning any records?
Thanks
Not too pretty but it works...
All Answers
Not too pretty but it works...