Error: Invalid Data. Review all error messages below to correct your data. Apex trigger SpawnDefaultLocation caused an unexpected exception, contact your administrator: SpawnDefaultLocation: execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: UNKNOWN_EXCEPTION, You're creating a duplicate record. We recommend you use an existing record instead.: []: Trigger.SpawnDefaultLocation: line 30, column 1
Set Location Details? If so, then it’s…
1
2
3
4
5
trigger SetLocationDetails on Location__c (before insert, before update) {
for (Location__c l : Trigger.new) {
l.Name = l.LocationName__c;
}
}
As per you code @ line 30 you are trying to insert locations(which is list of location__c object). And this is the line your are receiving the exception. So this indicates that the trigger on location object is throwing exception.
You have to post all the location__c objects triggers with before insert or after insert triggers. That will help us to find out this issue.
SetLocationDetails trigger looks good. Also plz check that if you have created any unique field on location object.
Sorry, I’m just an executive. Not an IT guy.
When I look at the list of the triggers the only things I see that are related to or mention locations are spawnlocation and the setlocationdetails.
Where would I find location__c objects triggers with before insert or after insert triggers?
And how would I know if we’ve got a unique field on the location object?
GoTo--> Develop --> Apex Triggers (It will display all the trigger in system)
Click on Sobject Type (column headers). This will sort all the triggers based on object.
Look for Location__c rows. If you have multiple row it means this object contains multiple triggers.
Click on each link and check whether it is implemented with after insert or before insert event. Ex trigger SetLocationDetails on Location__c (before insert, before update)
To find out unique field in location object.
GoTo--> Create--> objects --> location__c (click on link this will display page with fields in location object)
check fields with data type column as Unique. Ex: Email (Unique)
Review all error messages below to correct your data.
Apex trigger SpawnDefaultLocation caused an unexpected exception, contact your administrator: SpawnDefaultLocation: execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: UNKNOWN_EXCEPTION, You're creating a duplicate record. We recommend you use an existing record instead.: []: Trigger.SpawnDefaultLocation: line 30, column 1
Can you plz post the code, screen shot is not clear to see the code.
Plz check if there is any trigger or validation rule on Location objects.
As per you code @ line 30 you are trying to insert locations(which is list of location__c object). And this is the line your are receiving the exception. So this indicates that the trigger on location object is throwing exception.
You have to post all the location__c objects triggers with before insert or after insert triggers. That will help us to find out this issue.
SetLocationDetails trigger looks good. Also plz check that if you have created any unique field on location object.
To find out trigger by using below steps.
- GoTo--> Develop --> Apex Triggers (It will display all the trigger in system)
- Click on Sobject Type (column headers). This will sort all the triggers based on object.
- Look for Location__c rows. If you have multiple row it means this object contains multiple triggers.
- Click on each link and check whether it is implemented with after insert or before insert event. Ex
To find out unique field in location object.trigger SetLocationDetails on Location__c (before insert, before update)