You need to sign in to do that
Don't have an account?
nihar
i have created an apex class for creation of tasks in opportunity records
Hi all ,
My requirment is to create sort order for tasks .........
the tasks are created when opportyunity record is created ........
Example : 3)Task3 but i want output has 1)Task1, 2)Task2, 3)Task3 in order
2)Task2
1)task1
My code :
public class CompsureTasks_helper{
//Create tasks
public static void createTasks(List<id> oppId){
List<Opportunity> oppList = [select id,name,closedate,ownerid,Opportunity_Period__c from Opportunity where id IN : oppId];
List<Task> insertTasks = new List<Task>();
for(Opportunity opp : oppList){
//for Task1
task t = new task(OwnerId = opp.ownerid,Subject = 'Task1',Status = 'Open',Priority = 'Normal',WhatId = opp.Id);
integer tt = (integer)Math.round((15*opp.Opportunity_Period__c)/100);
system.debug('$$$'+tt);
t.activitydate = system.today().adddays((integer)Math.round((15*opp.Opportunity_Period__c)/100));
t.IsReminderSet = true;
t.ReminderDateTime = t.activitydate;
insertTasks.add(t);
//For Task2
task t1 = new task(OwnerId = opp.ownerid,Subject = 'Task2',Status = 'Open',Priority = 'Normal',WhatId = opp.Id);
t1.activitydate = system.today().adddays((integer)Math.round((20*opp.Opportunity_Period__c)/100));
t1.IsReminderSet = true;
t1.ReminderDateTime = t1.activitydate;
insertTasks.add(t1);
//For Task3
task t2 = new task(OwnerId = opp.ownerid,Subject = 'Task3',Status = 'Open',Priority = 'Normal',WhatId = opp.Id);
t2.activitydate = system.today().adddays((integer)Math.round((25*opp.Opportunity_Period__c)/100));
t2.IsReminderSet = true;
t2.ReminderDateTime = t2.activitydate;
insertTasks.add(t2);
}
insert insertTasks;
}
}
My requirment is to create sort order for tasks .........
the tasks are created when opportyunity record is created ........
Example : 3)Task3 but i want output has 1)Task1, 2)Task2, 3)Task3 in order
2)Task2
1)task1
My code :
public class CompsureTasks_helper{
//Create tasks
public static void createTasks(List<id> oppId){
List<Opportunity> oppList = [select id,name,closedate,ownerid,Opportunity_Period__c from Opportunity where id IN : oppId];
List<Task> insertTasks = new List<Task>();
for(Opportunity opp : oppList){
//for Task1
task t = new task(OwnerId = opp.ownerid,Subject = 'Task1',Status = 'Open',Priority = 'Normal',WhatId = opp.Id);
integer tt = (integer)Math.round((15*opp.Opportunity_Period__c)/100);
system.debug('$$$'+tt);
t.activitydate = system.today().adddays((integer)Math.round((15*opp.Opportunity_Period__c)/100));
t.IsReminderSet = true;
t.ReminderDateTime = t.activitydate;
insertTasks.add(t);
//For Task2
task t1 = new task(OwnerId = opp.ownerid,Subject = 'Task2',Status = 'Open',Priority = 'Normal',WhatId = opp.Id);
t1.activitydate = system.today().adddays((integer)Math.round((20*opp.Opportunity_Period__c)/100));
t1.IsReminderSet = true;
t1.ReminderDateTime = t1.activitydate;
insertTasks.add(t1);
//For Task3
task t2 = new task(OwnerId = opp.ownerid,Subject = 'Task3',Status = 'Open',Priority = 'Normal',WhatId = opp.Id);
t2.activitydate = system.today().adddays((integer)Math.round((25*opp.Opportunity_Period__c)/100));
t2.IsReminderSet = true;
t2.ReminderDateTime = t2.activitydate;
insertTasks.add(t2);
}
insert insertTasks;
}
}
your code is working fine. I'm getiing Output below screenshot
sorry i did not add some information to my question
when i completed task1 and task2
it showing output has task2
task1
Sorry, I'm not get your above post. give some more info.
In screen shot right side you can see the tasks......
but the tasks are in the order down to up order............but i want that tasks in reverse order(top to down order)...
that means last task should come first and so on and atlast first task should come last...............