You need to sign in to do that
Don't have an account?
mcrosby
Creating a Trigger that creates an Event
I am attempting to write a custom application for my organization that allows for a Time Off approval process. I am trying to create a trigger that will create an Event record for a user if their Time Off request has been approved.
I developed the trigger in my sandbox, and everything seems to work properly. However, I'm trying to work my way through deploying it to production and I'm running into a problem.
When I run the compileAndTest Ant script, I'm getting the following error:
System.DmlException: Update failed. First exception on row 0 with id a0FT0000000Arq8MAC; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, createTimeOffEvents: execution of AfterUpdate
caused by: System.DmlException: Insert failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id
Trigger.createTimeOffEvents: line 108, column 13
I believe the reason for this error is because I am attempting to set the OwnerId of the Event to a selected user id that is specified in the custom Time Off object.
Is there a way to allow triggers to set the OwnerId of a new record?
I developed the trigger in my sandbox, and everything seems to work properly. However, I'm trying to work my way through deploying it to production and I'm running into a problem.
When I run the compileAndTest Ant script, I'm getting the following error:
System.DmlException: Update failed. First exception on row 0 with id a0FT0000000Arq8MAC; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, createTimeOffEvents: execution of AfterUpdate
caused by: System.DmlException: Insert failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id
Trigger.createTimeOffEvents: line 108, column 13
I believe the reason for this error is because I am attempting to set the OwnerId of the Event to a selected user id that is specified in the custom Time Off object.
Is there a way to allow triggers to set the OwnerId of a new record?
hey
im trying to get time off to create an event when time off has been approved.
would it be possible to get the code for the trigger you created just so i can see how this works.
im new to using apex and need all the help i can get
I've abandoned this for now, but I think the following was working at one point. I had created a custom Time Off object with the fields specified in the following code. The logic below seemed to work for what we needed at the time. Good luck in getting yours developed.
NOTE: After looking at the code, there are a few things that would make better sense efficiency wise. This was one of my first attempts at creating a trigger. For example, it would be best to do a batch insert of events rather than looping through and creating one event record at a time. However, the above code might help you get a little further along in what you need to do.
Message Edited by mcrosby on 07-18-2008 09:50 AM