You need to sign in to do that
Don't have an account?
Specify "Assigned to" in Opportunity Event Trigger?
I have a trigger that, among other things, is creating some events on new opportunities. Here's that section of the trigger:
eventList.add(new Event(whatid=o.id,startdatetime=myDateTime,subject='Account Management Follow-Up', EndDateTime=myDateTime, IsAllDayEvent=true, OwnerId = 'cwilli'));
eventList.add(new Event(whatid=o.id,startdatetime=myDateTime.addMonths(2),subject='Account Management Follow-Up', EndDateTime=myDateTime.addMonths(2), IsAllDayEvent=true/*, OwnerId = 'cwilli'*/));
eventList.add(new Event(whatid=o.id,startdatetime=myDateTime.addMonths(4),subject='Account Management Follow-Up', EndDateTime=myDateTime.addMonths(4), IsAllDayEvent=true/*, OwnerId = 'cwilli'*/));
eventList.add(new Event(whatid=o.id,startdatetime=myDateTime.addMonths(6),subject='Account Management Follow-Up', EndDateTime=myDateTime.addMonths(6), IsAllDayEvent=true/*, OwnerId = 'cwilli'*/));
eventList.add(new Event(whatid=o.id,startdatetime=myDateTime.addMonths(8),subject='Account Management Follow-Up', EndDateTime=myDateTime.addMonths(8), IsAllDayEvent=true/*, OwnerId = 'cwilli'*/));
eventList.add(new Event(whatid=o.id,startdatetime=myDateTime.addMonths(10),subject='Account Management Follow-Up', EndDateTime=myDateTime.addMonths(10), IsAllDayEvent=true/*, OwnerId = 'cwilli'*/));
eventList.add(new Event(whatid=o.id,startdatetime=myDateTime.addMonths(10),subject='Renewal',EndDateTime=myDateTime.addMonths(10), IsAllDayEvent=true/*, OwnerId = 'cwilli'*/));
eventList.add(new Event(whatid=o.id,startdatetime=myDateTime.addMonths(2),subject='Account Management Follow-Up', EndDateTime=myDateTime.addMonths(2), IsAllDayEvent=true/*, OwnerId = 'cwilli'*/));
eventList.add(new Event(whatid=o.id,startdatetime=myDateTime.addMonths(4),subject='Account Management Follow-Up', EndDateTime=myDateTime.addMonths(4), IsAllDayEvent=true/*, OwnerId = 'cwilli'*/));
eventList.add(new Event(whatid=o.id,startdatetime=myDateTime.addMonths(6),subject='Account Management Follow-Up', EndDateTime=myDateTime.addMonths(6), IsAllDayEvent=true/*, OwnerId = 'cwilli'*/));
eventList.add(new Event(whatid=o.id,startdatetime=myDateTime.addMonths(8),subject='Account Management Follow-Up', EndDateTime=myDateTime.addMonths(8), IsAllDayEvent=true/*, OwnerId = 'cwilli'*/));
eventList.add(new Event(whatid=o.id,startdatetime=myDateTime.addMonths(10),subject='Account Management Follow-Up', EndDateTime=myDateTime.addMonths(10), IsAllDayEvent=true/*, OwnerId = 'cwilli'*/));
eventList.add(new Event(whatid=o.id,startdatetime=myDateTime.addMonths(10),subject='Renewal',EndDateTime=myDateTime.addMonths(10), IsAllDayEvent=true/*, OwnerId = 'cwilli'*/));
eventList.add(new Event(whatid=o.id,startdatetime=myDateTime.addMonths(9),subject='Sales Contract Follow-Up',EndDateTime=myDateTime.addMonths(9), IsAllDayEvent=true/*, OwnerId = 'cwilli'*/));
As you can see, I was trying to use the OwnerId field with a specific user's alias, but that was essentially destroying my trigger. I just need to know the correct syntax for specifying the assigned to field when I create these events. Thanks.
As you can see, I was trying to use the OwnerId field with a specific user's alias, but that was essentially destroying my trigger. I just need to know the correct syntax for specifying the assigned to field when I create these events. Thanks.
You can assign event owner as specific user by getting user detail by appllying allias or user name criteria filter on user object/table.
you should write below query at start of trigger out side loop.
You can Assign opportunity owner as event owner in after insert trigger
Best Regards,
-Vivek