Discussions
- General Development
- Schema Development
- Apex Code Development
- Visualforce Development
- Formulas & Validation Rules
- Security
- Mobile
- Force.com Sites & Site.com
- Chatter Development
- Java Development
- .NET Development
- Perl, PHP, Python & Ruby
- Desktop Integration
- APIs and Integrations
- Visual Workflow
- Apple, Mac and OS X
- VB and Office Development
- AppExchange Directory & Packaging
- Salesforce Labs & Open Source Projects
- Other Salesforce Applications
- Jobs Board
- Force.com Discussion Boards
- :
- Developer Boards for Force.com and Database.com
- :
- Apex Code Development
- :
- Event Trigger Stopped working
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Event Trigger Stopped working
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-28-2013 02:03 PM
I have a trigger that was creating an event based on the bid due date field. The trigger still creates the event but now if i change the date it no logger moves the event to the new date. Only thing that has changed was a similar trigger was created for another field, but i have deleted since this stopped working. Here is my code
trigger createTask on Opportunity (before insert, before update)
{
if(Trigger.IsInsert)
{
List<Event> events = new List<Event>();
List<Opportunity> Opps = Trigger.new;
for (Opportunity Opp : Opps){
Event evt = new Event(whatID = Opp.ID, Ownerid = Opp.OwnerID);
evt.Subject = 'Bid Due Date for ' + Opp.name;
evt.StartDateTime = Opp.Bid_Due_Date__C;
evt.EndDateTime = Opp.Bid_Due_Date__C;
Events.add(evt);
}
insert events;
}
if(Trigger.IsUpdate){
Map<ID, Opportunity> OppMap = new Map<ID, Opportunity>();
for (Opportunity Opp : Trigger.new){
if(Opp.Bid_Due_Date__C <> Trigger.OldMap.get(Opp.ID).Bid_Due_Date__C)
{
OppMap.put(Opp.ID, Opp);
}
}
List<Event> events = new List<Event>();
List<Opportunity> Opps = Trigger.new;
String Sub = 'Bid Due Date for%';
for(Event evt : [Select Id, Subject, WhatID, OwnerID, StartDateTime, EndDateTime FROM event WHERE WhatID IN : Opps and Subject like :sub])
{
Opportunity Opp = OppMap.get(evt.WhatId);
evt.StartDateTime = Opp.Bid_Due_Date__c;
evt.EndDateTime = Opp.Bid_Due_Date__c;
Events.add(evt);
}
Update events;
} }
Re: Event Trigger Stopped working
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-28-2013 05:13 PM
First check whether you could get any records from:
[Select Id, Subject, WhatID, OwnerID, StartDateTime, EndDateTime FROM event WHERE WhatID IN : Opps and Subject like :sub]
add a line of system.debug to print out evt.size().

