You need to sign in to do that
Don't have an account?
List has no rows for assignment to SObject
I am getting an error an just want to render the current choose task comments. Here is my code
public class TaskController{
public Task tsk{get;set;}
public TaskController(){
tsk=[select Id, Description from Task where Id = :ApexPages.currentPage().getParameters().get('id') limit 1];
tsk.Description=tsk.Description.replace('\n','<br/>');
}
}
<apex:page controller="TaskController" showHeader="false" renderAs="PDF">
<div align="center" width="550px">
<h1>Current Email</h1>
</div>
<div align="left" width="550px">
<apex:outputtext escape="false" value="{!tsk.Description}"></apex:outputtext>
</div>
</apex:page>
When I selected just the description it gave me the first item in the list.
You should use a List when performing that query.
ie:
Hi,
Instead of using object instance, use List to capture query SOQL result -
Ex. List<Task> tsk = new List<Task>();
tsk = [select Id, Description from Task where Id = :ApexPages.currentPage().getParameters().get('id') limit 1];
if(tsk.size()>o){
//your code will go here.
}
When I do so there is no value returned and the page is blank
Hi, There is no record for that ID you can add some validation before getting records.Example:
List<Task> temp=[select Id from Task where Id = :ApexPages.currentPage().getParameters().get('id') limit 1];
if(temp <> null && temp.size()>0)
tsk=[select Id, Description from Task where Id = :ApexPages.currentPage().getParameters().get('id') limit 1];
else
tsk = new Task();