+ Start a Discussion
Nithya S 1Nithya S 1 

Upsert is deleting a value

I am trying to upsert an contact based on a external ID field (x) and that should update/insert another external ID field (y).
So, the upsert inserts the contact based on x. But does not insert the value in the file to the field y, for a new contact.
When I tracked history for the field, y- it reads "deleted <value> from y"

Wouldn't it create the contact with the value?


David HalesDavid Hales
Hi Nithya,

Upserts basically is update+ insert. 
If the value is found it will update it or else it will insert it. 
There would be some different trigger or something working on it that would b deleting the value. 

Let me know if it helps

David Hales(Kspl 1058)
Hi Nithya,

To troubleshoot your scenario,
1. you should remove the Delete permission from the profile assigned against your user
2. Enable debug log(as we have removed the delete permission so now you will get deletion error)
3. In the error, you can identify the root cause(in which trigger/class delete is taking place).

Pawan Kumar

PS: Please let me know if it helps you.
Nithya S 1Nithya S 1

Hi Pawan/David,
I did enable the debug logs before, but there is no trigger that does delete the value from this field as this is an external ID. And this happens only the first time I do an upsert. The second time, when I try upserting the same data, the field y is updated.


Nithya S 1Nithya S 1
It seemed like it was a workflow rule that was causing it.
Thanks a lot!

David HalesDavid Hales
Hi Nithya, 

If it seemed to work please select my answer as best answer to help others and mark the question as solved. 

Best Regards 
David Hales(1058)