Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8843929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:21:32+00:00 2026-06-14T11:21:32+00:00

I have a record that when deactivated I want a plugin to automatically delete

  • 0

I have a record that when deactivated I want a plugin to automatically delete the record. So I have my code set to the SetStateDynamically event and it all works up to the point where I actually get the service to delete the record, where I get “An unexpected error occurred”.

My code is below, can anyone see what the problem might be, or be able to point me in the right direction?

Thanks

private void MarkForDeleteDeactivatedRole(EntityReference entity)
    {
        Entity role = Service.Retrieve("sb_contactsecurityrole", entity.Id, new ColumnSet(true));

        OptionSetValue statusValue = (OptionSetValue)role["statecode"];

        if (statusValue.Value == 1)
        {                
            Service.Delete(entity.LogicalName, entity.Id);
        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T11:21:33+00:00Added an answer on June 14, 2026 at 11:21 am

    I’ve seen the same. I don’t think the CRM event pipeline supports a record being deleted while it is working on that object. The best you’re probably going to be able to do is register your plug-in asynchronously, so the error (which you can’t catch, because it is in the CRM event pipeline internals) doesn’t bubble to the UI (and you’re outside of the transaction).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a record set that includes a date field, and want to determine
I have a list of record Id's that I want to retrieve from Sql
I have a record that has three fields and they are all dropdowns. It
I have a record that I want to hide only if the frontend user
I have a SQL Record that has number that are all out of order
I have the following code. I want to make a check box that will
I have 3000+ record in my database and I want to Display that record
I have a record that came from the follow linq query: using (var context
I have an audit record table that I am writing to. I am connecting
I have found the way to copy the record that I would like, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.