Announcement

Collapse
No announcement yet.

cannot trigger Workflow on "deleted == 1"

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • cannot trigger Workflow on "deleted == 1"

    Hi, when a record gets deleted I need to perform some clean up operations (get rid of subordinate records for example), so I have created a Workflow, that has the conditional action of:

    Code:
    deleted == 1
    When I check the workflow is never triggered.

    I also want to be able to reference the deleted flag on a parent record, so for example, when an Opportunity gets updated, I may want to see if the parent account has been deleted, and then delete the Opportunity.

    The Workflow trigger therefore becomes:

    Code:
    account.deleted == 1
    This never gets triggered either.


    While you are having a look into this area, I will also want to assign the deleted flag to items.

    I know I can assign it to the current item, and this works well.

    What I have not tested is assigning it to subordinate items, so for example, if an Opportunity gets deleted, I want to also delete the lower items.

    The Workflow action is then something like:

    Code:
    subordinate_record_link.deleted = 1;

    Help as always appreciated.

  • #2
    Hi Mat,

    When a record is deleted "update" is not triggered. Deletion is not treated as an update. You can use signal trigger type with '@delete' signal to catch deletion.

    Important: When the record is deleted the system can not access it anymore. You will have an access to record attributes that were loaded before deletion but nothing more. So usage of '@delete' is very limited.

    It's unlikely that you will be able to delete related records.
    Last edited by yuri; 05-20-2020, 11:23 AM.

    Comment


    • #3
      Yuri

      If this is not possible how do you remove items that are linked to others that also need to be deleted so that they do not mess up reports etc? E.g. if you have quotes on an opportunity and you delete the opportunity the quotes would still be there so the total value of quotes for opportunities report would be wrong.

      Comment


      • yuri
        yuri commented
        Editing a comment
        I'd recommend to change status to Closed Lost instead of deleting. Then with workflow > update related record you can change status of quotes.

    • #4
      That would work if every opportunity entered was perfect but they are not some get entered in error, duplication, for testing and demonstration purposes. this is also not the only example, there are many instances where if you deleted the master its subordinates would need also to be deleted.

      Comment


      • #5
        Hi Yuri, there are 3 issues with the proposal:
        1. for some situation you actually want the record deleted
        2. you cannot stop users from deleting records so we need a way to clean up
        3. I put this in to the "bug" section because a delete is an update. You can argue about semantics if needed, but the issus then becomes that we need another action on the Workflow to catch "delete" rather than use Update.

        Comment


        • #6
          I tried workflow with @delete signal, that runs Update Related Records with formula deleted = 1 and it worked. You could try it either. It's too much work on me. You can see that EspoCRM is developed mostly only by me and I also need to constantly monitor the forum, github, cases.

          It's a bad way to clean-up since you won'be be able to restore the deleted children w/o access to DB. In case you incidentally deleted the record that happens now and then.
          Last edited by yuri; 05-20-2020, 04:11 PM.

          Comment


          • #7
            Ooo, that is interesting thanks. When you say "Workflow" do you mean "Workflow" or BPM?

            Can you share a screen shot of how you caught the delete please?

            I appreciate your help. I do agree that a delete is a differed Database operation to an Update, I am just trying to make things work with what is available. Triggering a BPM/Workflow on Delete (in the same way as Update) would be the best solution, but I appreciate that is more work.

            Thanks

            Comment


            • #8
              It's workflow with signal type. It's been there a while. https://docs.espocrm.com/administrat...kflows/#signal

              Comment

              Working...
              X