Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation Errors 'ENTITY_IS_DELETED' While Saving when Parent gets Deleted As Well #39

Closed
sforcegarrett opened this issue Jun 3, 2014 · 59 comments

Comments

@sforcegarrett
Copy link

The non-profit starter pack relates Contacts(child) to Households(parent and custom object). When a single Contact is related to a single Household and one tries to delete the child contact the attached error is displayed.
roll up error

I believe what is occurring is the Declarative Roll Up code is trying to update the parent with a roll up number while the non-profit starter code is trying to delete it and a conflict occurs. Accounting for this issue may be an enhancement to this package but I thought I would offer this scenario. How can we properly account for ignoring the roll up count if the parent is being deleted programmatically when the child is deleted?

I am happy to provide login access to review this scenario if needs be. I seem to only be able to reproduce this in production at the moment.

@afawcett
Copy link
Collaborator

afawcett commented Jun 6, 2014

Sorry for the slow response on this one, I'm at the MVP Summit this week, will try to get to this between flights this weekend or later next week. Thank you for your patience.

@afawcett
Copy link
Collaborator

afawcett commented Jun 6, 2014

In the meantime have you tried configuring without using the Pilot UI, through the standard Salesforce Detail page?

@sforcegarrett
Copy link
Author

Yes...I actually didn't use the Pilot feature. Here is what the roll up record looks like.
screen shot 2014-06-09 at 10 58 19 am
No rush on this! I appreciate your help.

@sforcegarrett
Copy link
Author

Oddly enough I also can't reproduce this in sandbox yet. It is only in production. I am still trying to pin down why...

@afawcett
Copy link
Collaborator

Do you have any triggers on these objects in production that are not in sandbox?

@afawcett
Copy link
Collaborator

Happy to take a look through subscriber support login if you want to grant access, please give me the steps to reproduce and i'll see what i can see that might causing this! 👍

@afawcett
Copy link
Collaborator

Or maybe there is a way for me to install the non-profit starter pack in a test org of my own? As you say it may well be a conflict and ordering issue between the triggers on these objects. Would love to replciate the use case and add to the packages test suite.

@afawcett
Copy link
Collaborator

Excellent I've reproduced this by installing the packages and setting up a rollup as above! I'll get started debugging it!

@afawcett
Copy link
Collaborator

I think the reason why might be down to the order triggers execute, salesforce documents this as non-deterministic, so that might be the reason it works in sandbox (just seen it working as well in there).

@sforcegarrett
Copy link
Author

Great news! I am glad you can reproduce it. I agree with you...I think it is caused by the fact that we can not force certain triggers to run before others (just like workflow!).

So you are seeing it work in sandbox and fail in production as well?

@JodiNA
Copy link

JodiNA commented Aug 18, 2015

Hi all,

I'm actually experiencing this same issue in my sandbox, but not in production! It's a new sandbox, and so there shouldn't be anything different than production. Any suggestions?

Thanks!
Jodi

apex_error

@JodiNA
Copy link

JodiNA commented Aug 18, 2015

Strike that, it is also giving me issues in production. So it's not sandbox/production related. I'm also using NPSP.

@afawcett
Copy link
Collaborator

Hi this is an old and complex issue, not sure i ever did get round to debugging it looking at the trial, just in case though can you confirm your on the latest version of the tool?

@JodiNA
Copy link

JodiNA commented Aug 31, 2015

I'm using version 1.10. Thanks!

This particular instance of this issue for us may become mute soon, because we are about to upgrade to NPSP 3.0 and will be able to use a native roll-up summary field instead of the lookup tool. However, given that NPSP is managed and I can't see or modify any of the triggers, I'm guessing this issue will arise again with a different lookup.

@afawcett
Copy link
Collaborator

Ok, let me know, as your on quite an old version of the tool, it would be good to upgrade before retrying.

@JodiNA
Copy link

JodiNA commented Sep 2, 2015

Oye, yes. I didn't realize how behind I had gotten! I will do that and repost if I'm still having the issue!

@JodiNA
Copy link

JodiNA commented Sep 2, 2015

Here I am again. Now running 1.23 and still having the issue. :-(

@afawcett
Copy link
Collaborator

Ok. I'm heading out to DF next week, but have marked this issue as a priority for the next major chunk of time i get to look at this. I note that i did reproduce it earlier in this discussion. There does however seem to be a theme around the NPSP, i do wonder if we need to pool resources and setup a shared org to demo setup and/or reproduce issues in, just a thought.

@afawcett
Copy link
Collaborator

@JodiNA would you be able to help this issue and others around NPSP by setting up a free Developer Edition org with a repo of this issue?

@JodiNA
Copy link

JodiNA commented Nov 30, 2015

Hi Andy, happy to help. I set up a dev. org. so that it can be reproduced, but I'm getting stuck with installing NPSP. I'm not sure how to install it into a dev. org... Suggestions? I can easily replicate with NPSP 2, but not sure about NPSP 3 (I'm guessing the problem still comes up when triggers are involved, but I had a conflict yet).

@afawcett
Copy link
Collaborator

afawcett commented Dec 1, 2015

You should be able to install it into a dev org just like in production or sandbox? What issue are you having?

@afawcett
Copy link
Collaborator

afawcett commented Dec 1, 2015

Lets try with an org with NPSP 2 in it first, we can always upgrade in due course or create another org for NPSP 3.

@JodiNA
Copy link

JodiNA commented Dec 1, 2015

When I give my dev. org credentials when trying to install, it's giving me an error that I entered invalid credentials. I selected "install in sandbox" - perhaps that's not correct?

@JodiNA
Copy link

JodiNA commented Dec 11, 2015

Update - haven't had a chance to look into this further this week. Will try again early next week! (Dec. 14)

@JodiNA
Copy link

JodiNA commented Mar 21, 2016

Great to hear this is fixed, @afawcett! Or at least the part that was breaking from the rollup I set up!

I am going to go back and check about the original error I had, with NPSP 2. I'm curious if it was the same self-referencing issue and I didn't realize it.

The reason I did a rollup calculation on the same record (what you said, self-referencing) is that I wanted to create a Rollup Summary field on Accounts. It's not possible to use formula fields in Rollup Summaries, so this was how I did it. So, essentially, my options were to do one formula field on opportunities and then potentially a bunch of Lookup Summaries based off of that field, or one self-referencing Lookup Summary and then I can take advantage of the native SF functionality and do multiple rollup summaries off of that. I chose the latter. Does that make sense?

Another alternative would have been to do a workflow rule on the opportunity to update the field, but that doesn't quite work either because there isn't a good way to trigger revaluation of the records the way I can do with DLRS.

Hope that helps as an explanation!

@JodiNA
Copy link

JodiNA commented Mar 21, 2016

I'm going to try to set up the the rollup I was getting with Households in the developer org for repro and testing.

@JodiNA
Copy link

JodiNA commented Mar 21, 2016

Hi again! @afawcett I set up another rollup in the dev. org which mimics one of the issues I was having. The rollup is called "Household Member IDs." The rollups concatenates the IDs of all contacts in a Household. The error occurs when you try to delete a contact.

The caveat is that the contact must have a Household. Because the account model is Households, a household will not be generated automatically. To reproduce the error, I went and manually created a Household for Test Contact.

The error is the following:

Validation Errors While Saving Record(s)
There were custom validation error(s) encountered while saving the affected record(s). The first validation error encountered was "Apex trigger dlrs_ContactTrigger caused an unexpected exception, contact your administrator: dlrs_ContactTrigger: execution of AfterDelete caused by: System.DmlException: Update failed. First exception on row 0 with id a0336000001uRGmAAM; first error: ENTITY_IS_DELETED, entity is deleted: []: (dlrs)".

@JodiNA
Copy link

JodiNA commented Mar 21, 2016

Hi again. I was able to recreate the last weird NPSP error I was getting in one of my sandboxes that is still on NPSP 2 and using the One-to-One account model. I tried to recreate in the dev org, but I wasn't able to get the problem to occur. So, maybe it's a non-issue, but I figured I should document it anyhow.

But, these are the steps and problem:

  1. Create a rollup summary that rolls up from the ghost account (one-to-one account) to the contact. I did this in the dev. org copying the one I have in my Sandbox (also in image). It's called "One-to-One IDs".
  2. Create a contact.
    Result: Upon saving the new contact, not one, but TWO Household records will have been created. One will be connected to the contact via lookup, and the other will be unrelated (find in search).

To test in the dev. org, I change the Account Model to "One-to-One." Then I selected under the Household setting Household Object Rules "All Individual Contacts." These two settings ensure that a ghost account is created for each contact, and the field in the rollup will be populated.

Here is a screencast of the error happening in my sandbox. View of the rollup is attached.
http://www.screencast.com/t/oH9TdvFHk3
one-to-one_ids

@afawcett
Copy link
Collaborator

Ok i've been trying to recreate your Contact delete issue first, can you reset the org and confirm the steps to reproduce this error and we can start with this one.

Regarding your explanation on the self referencing rollup, it's probably me, but i'm not really getting it as yet. But lets focus on the Contact issue for the mo... 👍

@afawcett
Copy link
Collaborator

I have setup this a tag to group NPSP related issues.

So we can see if we can team up on what i think is a general issue. My personal challenge is i don't have any knowledge of NPSP. @JodiNA over in issue #39 has kindly worked with to setup a reproduction org with DLRS and NPSP installed within.

This has already led to one issue being resolved in v2.3 lets see if we can close in on more. I'm happy to create users in this org so we can work to reproduce the issues in that org and i can debug more easily, just message me via SF Community or DM via Twitter your email and i'll setup a user.

@JodiNA
Copy link

JodiNA commented Mar 22, 2016

To reproduce the contact delete issue:

  1. Ensure that the Lookup Summary "Household Member IDs" is active and is set to realtime calculations.
  2. Create a new contact.
  3. Create a new household (not household account, which will be created automatically upon contact creation)
  4. Return to new contact. Lookup new household from contact record.
  5. On HH record, confirm that Household Member ID field is populated (via rollup). The household name will have changed to "Anonymous Household" (this is due to something else.. .just ignore for now)
  6. Attempt to delete contact.

Let me know if that doesn't work!

I've left the NPSP account model to the newly recommended setting, which is why the household is not generated automatically. If needed, I can change the settings. But I thought it would be more useful to be using the model that more orgs are likely to be using.

@afawcett
Copy link
Collaborator

Thanks! 👍

@afawcett
Copy link
Collaborator

Ok great, reproduced it! Now to dig in... 👍

@JodiNA
Copy link

JodiNA commented Mar 25, 2016

Sweet!

On Friday, March 25, 2016, Andrew Fawcett <[email protected]
javascript:_e(%7B%7D,'cvml','[email protected]');> wrote:

Ok great, reproduced it! Now to dig in... [image: 👍]


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#39 (comment)

Jodi Nemser-Abrahams
Information & Data Manager
Keshet
284 Amory Street
Jamaica Plain, MA 02130
617.524.9227x111

Web: www.keshetonline.org
Facebook: www.facebook.com/KeshetGLBTJews
Twitter: @KeshetGLBTJews https://twitter.com/KeshetGLBTJews
Blog: www.myjewishlearning.com/category/keshet/

Subscribe for LGBT Jewish news, resources and inspiration in your inbox
http://bit.ly/1E6oJYK.

Registration http://www.keshetonline.org/teenshabbaton/ for our first
ever West Coast Shabbaton for LGBTQ and ally teens is open! *Find more
information *here
http://www.keshetonline.org/teenshabbaton/.

Stand up for transgender rights. Sign Keshet's petition
https://www.keshetonline.org/work/petition-in-support-of-full-transgender-rights-in-massachusetts/support-transgender-rights-in-ma/
calling
Massachusetts legislators to support “An Act Relative to Transgender
Anti-Discrimination."

A teen. A mom. A straight rabbi and a queer rabbi.
See how we are transforming the Jewish community together
https://youtu.be/3b8NL5jwt4o.

@afawcett
Copy link
Collaborator

These NPSP related issues have been open a while. Prior to an MVP event in Chicago this year, i did put out a shout out to get together with an NPSP dev to debug this further (my prior attempts failed since i cannot see the NPSP and lack the knowledge to set it up unmanaged). I did get some response from my Chatter post. The general view though was that these are NPSP v2 issues and that the use of NPSP v3 is recommended. So my questions are... do those on this issue agree re: NPSP v2? And if so should we try to reproduce these on NPSP v3 or is the issue even known to exist on NPSP v3?

@afawcett afawcett removed the priority label Aug 15, 2016
@ashimasaigal
Copy link

Andrew, I do believe this is an issue with NPSP V3, so I can help you with this. It seems you need an unmanaged package installation of the NPSP V3 in an Org. Let me know see if I can create one and add you as an Admin to that. Would that help? I can likely help debug as well, if that would be helpful. Let's chat, I want to help with this one.

@afawcett
Copy link
Collaborator

Oh yes please, that will be great. Yes lets get a dev org up and running, deploy both unmanaged into it and attempt to reproduce. Happy to do a screenshare or whatever to collaborate. So yes please, if you create an org, deploy NPSP into it, create me an admin user and i'll push DLRS unmanaged into it, then pass it back to you to repo, hows that sound?

@ashimasaigal
Copy link

ashimasaigal commented Aug 15, 2016

I'm happy to do that Andrew. I'll work to get the dev org set up and you added. Should I use [removed] as your email or another email address? I'll let you push the DLRS into the instance and then I'll play and create the issue, okay?

You're the best!

@afawcett
Copy link
Collaborator

Yep that email is fine.

@wyan-carter
Copy link

Hi Andrew,

I'm having this issue too unfortunately, and I'm on v3.85 of the NPSP, and 2.4.2 of the DLRS tool. The error I'm getting is when there is only one contact connected an NPSP household, and we attempt to change the account that the contact is connected to. It seems the NPSP is attempting to delete the old household at the same time that the DLRS is attempting to update it. We have a process workaround thankfully, so it's not urgent, but I thought it would be worth reporting. Let me know if you need any more info from me. Thanks Andrew.

Wyan

@wyan-carter
Copy link

I should say that we do have a process workaround, but it's actually very tricky to fix issues. We have to either delete the contact and recreate, or create a dummy additional contact record in the household that then gets deleted when we manually delete the superfluous household record. Would be great to have a solution!

@afawcett
Copy link
Collaborator

afawcett commented Dec 9, 2016

Thanks @wyan-carter always great to get more insights like this, appreciate this.

@afawcett
Copy link
Collaborator

afawcett commented Jan 9, 2017

Thanks to everyone on this issue an others, i have now just applied a fix to v2.7 to address this issue. Basically making the tool tolerant of errors occurring when the parent record has been deleted by child trigger logic. As triggers fire in non-deterministic times, this bug has also been quite hard to pin down, as well as needing NPSP installed and configured in a way i can debug. Thank you all for your help! Fixed in v2.7!

@wyan-carter
Copy link

Brilliant, thanks Andrew! Really appreciate your hardwork on making this tool better, we rely on it for so much. Thanks again.

@rahulshukla1910
Copy link

rahulshukla1910 commented Mar 3, 2021

Getting below Error While converting the lead and selecting the Account Type "HouseHold" how can we change the default record type, as it always considering Household only but i need to map another one "Organization Record type" once i will convert the lead and selected the account type "Organization".
Error: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, npsp.TDTM_Address: execution of AfterInsert caused by: System.DmlException: Delete failed. First exception on row 0 with id a0K6s000000Phf8EAC; first error: ENTITY_IS_DELETED, entity is deleted: [] (npsp): []
*Record Owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants