You need to sign in to do that
Don't have an account?
Trap and handle specific error instance while inserting record into custom object
I manually insert a record inserted into a custom object. One of the fields is a "Lookup(Contact)" to the Contact object.
This object does not require the Conttact field to be populated when manually entering and saving a record, it saves fine. However, when the record is saved I fire a trigger to run some code. if the Contact field is not populated, the trigger throws an error and it's code does not run. What is the way to solve this?
1) I could tell my users that they are required to populate that field, maybe with a dummy Contact.
2) I could trap the error and somehow allow the trigger code execution to continue.
I'm using Try Catch.
This is my error:
08:35:09.479 (479495000)|EXCEPTION_THROWN|[118]|System.DmlException: Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id not specified in an update call: []
What could I put here to catch and allow the record to update anyway?
catch (Exception e) {
}
Thanks for any help.
Kevin
For instance you might place a System.debug(myInstance); call just before your trigger updates.