You need to sign in to do that
Don't have an account?

How does one 'update original object using an update DML operation'?
In the Apex Language reference, on page 168, in 'Table 52: Actions and trigger events', there is a column called 'Can update original object using an update DML operation'. How does one do this? I have looked through the entire language reference, and am unable to find out how this is done.
Thanks so much for the response. I have read that section, but am still at a loss. I am trying to access an object to update it during an 'after undelete' call.
In order to update the record in question, I have to be able to fetch the record. However, I am not able to identify how to fetch the ID for the record in question, or fetch the record itself in an 'after undelete' trigger.
Can anyone help me identify how to fetch the record?
Message Edited by m_roark on 11-15-2007 02:17 PM
see pg. 167
Message Edited by sparky on 11-15-2007 02:56 PM
I get a null pointer exception when I attempt to access the object using 'Trigger.new' in the 'after undelete' trigger. The documentation you referenced says that you can only access Trigger.new during an 'insert' or 'update' trigger, and Trigger.old during an 'update' or 'delete' trigger.
I get the following error message when I attempt to reference the object using Trigger.new
Force.com Sandbox
Apex script unhandled trigger exception by user/organization:
checkInventory: execution of AfterUndelete
caused by: System.NullPointerException: Attempt to de-reference a null object
Trigger.checkInventory: line 229, column 21
Here is the code that is failing:
Code: Basically, I am working on an Inventory management system. If a request for Inventory is being undeleted, I want to set it to a status of 'Backordered' if insufficient inventory exists to fill the request. However, I can't seem to get at the undeleted record to update the status.
Is the error happening on that 2nd line in your snippet? Where does the requestItem variable come from?
The 'requestItem' variable is the Integer I use for iterating through the items in the 'Trigger' array.
The complete code looks something like this
Code: As for where the issue is occurring, as near as I can tell, it happens once I try to access any of the field values for the 'newRequestItem' variable, which is simply the current object in the 'Trigger.new' array. In this case, the error occurs when I attempt to extract the ID for the record from the 'newRequestItem' variable.
is it this line that's throwing the error, then? :
if so, the only things I can think of are:
* use id var type instead of string (not sure that matters)
* are you sure that the record will have anything in the Inventory__c field?
* are you sure you got the field name right?
Message Edited by sparky on 11-15-2007 04:38 PM
Thanks for the suggestion. After some judicious debugging, I identified that the 'currentInventory.Quantity_backordered__c' variable was null, and as such was triggering the 'Null Reference Exception'.
This was because I was attempting to use the '+=' operator to increment and assign to this variable, and this is not a valid operator when the variable value is null.
I added a check for null, and am past this error.
Code: Thanks again for your assistance.