function readOnly(count){ }
Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
public static void insert task
{
For each agent in agent role
instantiate task obj
populate task object
insert task
}
how to write for each in apex.....
You'd use the for( datatype varname : collectionvar ) syntax. Given you've provided only pseudo-code, here's a hypothetical use case:
Task[ ] tasks = new Task[ 0 ]; for( user agent : [SELECT Id FROM User WHERE Role.Name = 'Some Role'] ) { tasks.add( new Task( OwnerId = agent.id, subject = 'To-Do', ActivityDueDate = Date.Today( ).addDays( 7 ) ) ); } insert tasks;
You'd use the for( datatype varname : collectionvar ) syntax. Given you've provided only pseudo-code, here's a hypothetical use case: