You need to sign in to do that
Don't have an account?
SalesforceLearnerNewbie
Load the Task elements based on Subject and then print the element
Hi,
I wish to load the list inside the Task while at the same time I wish to understand some of the basics.
Example,
public List<Task> allSubject {get;set;} // why do we use List<Task> and not List<String>?
allSubject = [select Subject from Task];
for (Task a : allSubject){
//what to use here so that it will take the element inside Object/Dictionary 'Task'?
// After taking the Task, then I wish to only take the values for 'Subject'
}
System.debug(//here I wish to check the value for 'Subject')
thank you.
I wish to load the list inside the Task while at the same time I wish to understand some of the basics.
Example,
public List<Task> allSubject {get;set;} // why do we use List<Task> and not List<String>?
allSubject = [select Subject from Task];
for (Task a : allSubject){
//what to use here so that it will take the element inside Object/Dictionary 'Task'?
// After taking the Task, then I wish to only take the values for 'Subject'
}
System.debug(//here I wish to check the value for 'Subject')
thank you.
1. public List<Task> allSubject {get;set;} // why do we use List<Task> and not List<String>?
This is because, In SOQL you're querying the Task object and storing into list, so ofcourse the list should be of type Task or sObject not others.
2. List<Task > lstTask = [SELECT Subject FROM Task];
for(Task a: lstTask) {
a.Subject = 'Some Value'; //Using the object(a) created for Task we can access the queried values (like : a.Subject)
System.debug(' Subject :' +a.Subject);
}
Please let us know if this helps
Thanks,
Govindaraj.S
All Answers
1. public List<Task> allSubject {get;set;} // why do we use List<Task> and not List<String>?
This is because, In SOQL you're querying the Task object and storing into list, so ofcourse the list should be of type Task or sObject not others.
2. List<Task > lstTask = [SELECT Subject FROM Task];
for(Task a: lstTask) {
a.Subject = 'Some Value'; //Using the object(a) created for Task we can access the queried values (like : a.Subject)
System.debug(' Subject :' +a.Subject);
}
Please let us know if this helps
Thanks,
Govindaraj.S