function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
KerstinVKerstinV 

Custom Sync Trigger throws self reference error

Hello everyone,

I have a custom trigger in my Org to do some data changes before insert. Therefore I implemented some code even evaluating if it was triggered isBefore and then doing some update:

        System.assert(Trigger.isBefore);
        for (Integer i =0; i < oppLineItems.size(); i++) {
            invoiceLineItems[i].opp_ref__c = oppLineItems[i].Id;
        }

But still I get an error: SELF_REFERENCE_FROM_TRIGGER.
Any suggestions or ideas?

The thing is, it was working just fine for half a year but now (in relation to the last release ?!?) it is not working since about two weeks?

It would be awesome to get some hints on this one!
SwethaSwetha (Salesforce Developers) 
HI KerstinV,
SELF_REFERENCE_FROM_TRIGGER error from Apex indicates that you have attempted to update or delete a record that is already being updated by another trigger.

There could be direct /indirect operations that cause Apex error as mentioned in https://help.salesforce.com/s/articleView?id=000324391&type=1

I know this is an old post to conclude if this is release-related or not but if you are still facing this issue, can you provide more details like what the logs show so I can suggest. 

Related: https://salesforce.stackexchange.com/questions/269585/before-update-trigger-self-reference-from-trigger-error/269601#269601
https://salesforce.stackexchange.com/questions/113626/getting-self-reference-from-trigger-error-on-my-new-sf-trigger

If this information helps, please mark the answer as best. Thank you