+ Start a Discussion
Renier NavasRenier Navas 

Error Occurred: INSERT --- INSERT FAILED --- ERRORS : (ENTITY_IS_DELETED) entity is deleted

Hi - we have a custom workflow(wizard) to convert a referral(case) into a client. Just recently the workflow started producing the error: INSERT --- INSERT FAILED --- ERRORS : (ENTITY_IS_DELETED) entity is deleted,

User-added image

Doing some testing I found out that if the firts decision block  called "Dupe Client?" finds a duplicate (Client Found), the wizard works fine. But, if there is not a match, then I get the error when the workflow tries to create the new contact record. 

Any help as always apreeciated. Not sure why suddley the workflow stoped working and I can't find much information to help me get this resolved.

Here is my error report:

Flow Details
Flow Name: Convert_Referral
Type: Flow
Version: 4
Status: Active
Flow Interview Details
Interview Label: Convert Referral 8/1/2016 1:44 PM
Current User: Renier Navas (0051a000000URsY)
Start time: 8/1/2016 1:44 PM
Duration: 8 seconds
How the Interview Started
Renier Navas (0051a000000URsY) started the flow interview.
Some of this flow's variables were set when the interview started.
var_ReferralId = 50055000004KOE6AAO
FAST LOOKUP: Lookup_Referral
Find all Case records where:
Id Equals {!var_ReferralId} (50055000004KOE6AAO)
Assign those records to {!svar_Referral}.
Save these field values in the variable: c4g_Web_First_Name__c, c4g_Web_Last_Name__c, SuppliedEmail, SuppliedPhone, c4g_Birthdate__c, c4g_Sex__c, c4g_Street_Address__c, c4g_City__c, c4g_State__c, c4g_County__c, c4g_Zip_Code__c, Type, c4g_Intake_Date__c
Result
Successfully found records.
RECORD QUERY: Lookup_Contact_Dupe
Find one Contact record where:
FirstName Contains {!svar_Referral.c4g_Web_First_Name__c} (Mike)
MailingCity Equals {!svar_Referral.c4g_City__c} (null)
LastName Equals {!svar_Referral.c4g_Web_Last_Name__c} (garber)
MailingState Equals {!svar_Referral.c4g_State__c} (null)
MailingStreet Equals {!svar_Referral.c4g_Street_Address__c} (null)
Result
Failed to find record.
DECISION: Dupe_Client
Executed this outcome: No_Match
Outcome conditions: and
1. {!Lookup_Contact_Dupe} (false) Equals false
Logic: All conditions must be true (AND)
RECORD CREATE: Create_Client_Contact
Create one Contact record where:
Birthdate = {!svar_Referral.c4g_Birthdate__c} (null)
FirstName = {!svar_Referral.c4g_Web_First_Name__c} (Mike)
HomePhone = {!svar_Referral.SuppliedPhone} (null)
LastName = {!svar_Referral.c4g_Web_Last_Name__c} (garber)
MailingCity = {!svar_Referral.c4g_City__c} (null)
MailingPostalCode = {!svar_Referral.c4g_Zip_Code__c} (null)
MailingState = {!svar_Referral.c4g_State__c} (null)
MailingStreet = {!svar_Referral.c4g_Street_Address__c} (null)
RecordTypeId = 0121a000000dTwK
c4g_Primary_County__c = {!svar_Referral.c4g_County__c} (null)
c4g_Sex__c = {!svar_Referral.c4g_Sex__c} (Male)
npe01__HomeEmail__c = {!svar_Referral.SuppliedEmail} (null)
npe01__PreferredPhone__c = Home
npe01__Preferred_Email__c = Personal
npe01__Primary_Address_Type__c = Home
npsp__is_Address_Override__c = true
Result
Failed to create record.

Error Occurred: INSERT --- INSERT FAILED --- ERRORS : (ENTITY_IS_DELETED) entity is deleted,


 
Best Answer chosen by Renier Navas
Renier NavasRenier Navas
Thanks Vineet. I actually was able to pin point the issue. 

It has to do with a NPSP field to override the defult address for a contact. (https://www.youtube.com/watch?v=LO4LUzZVDlE&index=2&list=PLU8xqF8ZASbXWAHIF0SB1P9_3G4vvRMXI)

For some reason, and that must be after an update of the NPSP package, the flow now won't create the contact record if this field is set to the global constact TRUE, and in the referral (case) record there is not address entered. If the referral  (case) has an address, the flow works fine. So, for now our solution is removing the npsp_is_Address_Override_c = TRUE from the record create block, because we normally don't have the client's address at the moment the referral is converted. The check box can be checked after when editing the contact record, as showed in the video above. 

User-added image

 

All Answers

VineetKumarVineetKumar
Before creating you should put some filter on the fields that you are looking up and referring to.
Some thing like, if no records found, the don't go for record creation.
Renier NavasRenier Navas
One more comment. Maybe the error is caused by the Apex code in the the VisualForce page that initiates the flow?

<apex:page standardController="Case">
<apex:variable var="theCase" value="{!Case.Id}"></apex:variable>
<flow:interview name="Convert_Referral" finishLocation="{!URLFOR('/'+theCase)}" >
<apex:param name="var_ReferralId" value="{!Case.Id}"/>
</flow:interview> 
</apex:page>
Renier NavasRenier Navas
BTW, I am new to this, so not an expert and just learning. 
VineetKumarVineetKumar
Can be, if no case Id is passed then no records would be found,
That's the reason I said, to but null check in the criteria to avoid firing for no reason.
something like : var_ReferralId not equals <blank>
Renier NavasRenier Navas
Thanks Vineet. I actually was able to pin point the issue. 

It has to do with a NPSP field to override the defult address for a contact. (https://www.youtube.com/watch?v=LO4LUzZVDlE&index=2&list=PLU8xqF8ZASbXWAHIF0SB1P9_3G4vvRMXI)

For some reason, and that must be after an update of the NPSP package, the flow now won't create the contact record if this field is set to the global constact TRUE, and in the referral (case) record there is not address entered. If the referral  (case) has an address, the flow works fine. So, for now our solution is removing the npsp_is_Address_Override_c = TRUE from the record create block, because we normally don't have the client's address at the moment the referral is converted. The check box can be checked after when editing the contact record, as showed in the video above. 

User-added image

 
This was selected as the best answer