web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)
Answered

Prevent delete of Record

(0) ShareShare
ReportReport
Posted on by 6,211

Hi All,

On a delete operation, i want to prevent delete of record and inactive that record.

Any help would be appraicted.

Regards,

Shahbaaz

*This post is locked for comments

I have the same question (0)
  • Kokulan Profile Picture
    18,054 on at

    Create a real-time workflow that triggers on Delete and in this workflow call a child background workflow to change the status to inactive.

    And then call the Stop Workflow with Cancelled state with message to say record cannot be deleted and it will be deactivated.

  • Shahbaaz Ansari Profile Picture
    6,211 on at

    Hi Kokulan,

    Didn't worked.

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi Shahbaaz,

    Try to do using real time workflow entity delete event , if the status is inactive , stop workflow with cancelled status.. I have just tested its working for me .

    2019_2D00_03_2D00_04_5F00_16_2D00_31_2D00_09.jpg

    2019_2D00_03_2D00_04_5F00_16_2D00_31_2D00_09.jpg

  • Shahbaaz Ansari Profile Picture
    6,211 on at

    Thanks gautam for the reply, could you provide any screenshot of such workflow?

  • gdas Profile Picture
    50,091 Moderator on at

    I have uploaded the screenshot , please have a look.

  • Shahbaaz Ansari Profile Picture
    6,211 on at

    along with that, it should inactivated that record

    for that i have created background child workflow, but it is not deactivating the record

  • Suggested answer
    Rawish Kumar Profile Picture
    13,758 on at

    @Kokulan - it looks like as soon as we stop the workflow with error -it rollback everything or stop the trnsaction. Hence the record will not be update to inactivate.

    I have tried to make the child workflow as background to deactivate the record but it doesnt work.

    @Shahbaaz. I think you need to use a simple plugin.  

    register your plugin pre-operation of delete

    and check if status =active

    {

    update the status to inactive

    service.Execute(new SetStateRequest

    {

       EntityMoniker = new EntityReference("contact", contactId),

       State = new OptionSetValue(1),

       Status = new OptionSetValue(-1)

    });

    then throw invalidpluginexecutionexception which will stop the  deletion.

    }

    docs.microsoft.com/.../gg308277(v%3Dcrm.8)    

  • Shahbaaz Ansari Profile Picture
    6,211 on at

    Thanks rawish for the reply, from my understanding if you throw exception from plugin pre operation, it will also rollback all your change's.

    Please correct me if i am wrong.

  • Verified answer
    Alex Fun Wei Jie Profile Picture
    33,628 on at

    Hi,

    why dont you remove the delete privilege from security role and educate your user to use deactivate button.

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    Sorry , I got your point now. There is two scenario for two status (Active and Inactive )so you can create two real time workflow .

    First workflow look like below -

    If Status equal Active

    Update case to Inactive

    In that case you will get same message that  inactive record can not delete.

    Second workflow will be look like above which I shared , stop deletion of inactive reocords.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans