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
Philip Essien 8Philip Essien 8 

Issue with formula fields..


Create a formula field that determines the number of days between today and the last activity date for a case's account.
Your support team has asked for improved visibility on account activity level at the time they’re helping with customer issues. Specifically, when they’re looking at a case, they’d like to see an at-a-glance view of the number of days since the case’s related account was last active. Create the formula using these requirements.The formula should be on the Case object.
The formula should be of return type Number.
The formula should be named 'Days Since Last Update' and have a resulting API Name of 'Days_Since_Last_Update__c'.
The formula should return the number of days between the account’s Last Activity Date and today.

I tried doing this using this formula. TODAY()  -  Account.LastActivityDate  No errors on the formula but I get this when I try to check challenge.

Challenge Not yet complete... here's what's wrong: 
There was an unexpected error in your org which is preventing this assessment check from completing: System.DmlException: Delete failed. First exception on row 0 with id 0016100000JUWKJAA5; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, You can't delete this record!: []

I need help with this. Thanks in advance.

 
Best Answer chosen by Philip Essien 8
Philip Essien 8Philip Essien 8
I finally figured out what the problem was. I had an active RestrictAccDels trigger on the account object. I made it inactive and now I can move on.

trigger RestrictAccDels on Account (before delete) {
    if (Trigger.isDelete && Trigger.isBefore) {
    //In a before delete trigger, the trigger accesses the records that will be deleted with the Trigger.old list.
        for (Account a : Trigger.old) {
            if (a.name != 'okToDelete') {
                system.debug('Record: '+a.name+' failed to delete');
                a.addError('You can\'t delete this record!');
                continue;
            }
            system.debug('Successfully Deleted Record: '+a.name);
        }
    }
}

Thanks guys for your post. It did point me in the right direction. 

All Answers

DavidGantDavidGant
Philip,

Do you have any Validation Rules turned on for either the Case or Account object? If so, try deactivating those and rechecking the challenge. Looks like there is a VR that is trying to prevent deletion of a record. Based on the Id in your error, I would say it is an Account-level VR.

David
William TranWilliam Tran
It looks like you have a validation rule(s) stopping you from completing the Challenge.

Try go and delete the validation rule: FIELD_CUSTOM_VALIDATION_EXCEPTION

and try completing the challenge again.

As a common practice, if your question is answered, please choose 1 best answer.
But you can give every answer a thumb up if that answer is helpful to you.

Thanks
Philip Essien 8Philip Essien 8
Philip Essien 8
I don't have any active validation rules for both the Account and the Case object. I have 3 active workflow rules on the Case object. I just deactivated them and still the same problem.
William TranWilliam Tran
Same error?  Why are you getting a DELETE error?  "You can't delete this record!: []"

Are you trying to delete something?

It may be best to logout of everything and come back it, it may clear things up.

Thx
DavidGantDavidGant
The delete is probably part of the code that executes when checking the challenge. I'm not sure why it is throwing this error if there isn't an active validation rule since that is the type of error being returned. I recommend that you make sure you are logged in to your dev org and not a production/sandbox org for your company.
Philip Essien 8Philip Essien 8
I finally figured out what the problem was. I had an active RestrictAccDels trigger on the account object. I made it inactive and now I can move on.

trigger RestrictAccDels on Account (before delete) {
    if (Trigger.isDelete && Trigger.isBefore) {
    //In a before delete trigger, the trigger accesses the records that will be deleted with the Trigger.old list.
        for (Account a : Trigger.old) {
            if (a.name != 'okToDelete') {
                system.debug('Record: '+a.name+' failed to delete');
                a.addError('You can\'t delete this record!');
                continue;
            }
            system.debug('Successfully Deleted Record: '+a.name);
        }
    }
}

Thanks guys for your post. It did point me in the right direction. 
This was selected as the best answer
silpa garikapatisilpa garikapati
Hi 
I am getting  error to view the record in lightning .Error  i.e;
Unfortunately, there was a problem. Please try again. If the problem continues, get in touch with your administrator with the error ID shown here and any other related details.
This record could not be loaded because it includes too many formula fields with complex formulas, or too many custom fields. Ask your Salesforce administrator to remove some formula fields or simplify the formulas in use.

Pleae help me how to overcome this issue.