Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Answered

Catch event in workflow (create, delete)

Posted on by 415

Hi,
I'd like to create a workflow that triggers on both delete as create of a record:
2019_2D00_12_2D00_03_5F00_11_2D00_40_2D00_06.jpg

Is there any way in which I can identity what event triggered the workflow? I've seen solutions in which the createdon and modifiedon attributes are compared, but that won't work, since those will stay the same until deletion (not much happening in this entity). For maintenance purposes I would really like to refrain from creating two seperate flows.

Any thoughts?

Thanks in advance,
best regards
Jeroen

  • Jeroen J Profile Picture
    Jeroen J 415 on at
    RE: Catch event in workflow (create, delete)

    @Amit, @Joana, thank you both for your help. I think I found the right way of looking at this quest!

  • Verified answer
    RE: Catch event in workflow (create, delete)

    That's why I asked to call an action which will check the comparing logic. When the logic will start working at that time created on time and modified on time will not be the same for deletion. But they will be same for the creation.

    1) if (created on == modified on) then create a record in the custom entity with a fields action = create

    2) if (created on != modified on) then create a record in the custom entity with a fields action = delete

    there won't be third scenario as this workflow will run in case of create and delete only.

  • Verified answer
    Joana Pinto Profile Picture
    Joana Pinto 740 on at
    RE: Catch event in workflow (create, delete)

    Hi,

    You could create a new field (for internal use, hidden). Let's say "new_recordcreated", a two option field.

    Then, on that workflow where you want to identify the event, you would have an IF:

    IF(new_recordcreated == null)

    THEN update new_recordcreated = YES // if the field is null, it means the event is CREATE. Do your logic on the create event.

    ELSE

    //do something and it means that you are on the DELETE event, because your field was update on the CREATE event.

    This works because a record can only be deleted if it already exists, which means it passed on the CREATE event.

    Hope I was clear enough :)

  • Jeroen J Profile Picture
    Jeroen J 415 on at
    RE: Catch event in workflow (create, delete)

    Hi Amit,

    Thanks for your quick response.

    I'd like to use a scenario like your 1), but the problem is that modified and createdon stay the same all the time. So when I delete the record, these dates are still the same and the workflow acts as if it's a create.

  • RE: Catch event in workflow (create, delete)

    Hi Jeroen,

    You can implement the below logic in the action part of this workflow by calling an action from it.

    1) if created on == modified on then it's the case of "Create" else it's the case of delete.

    2) You can also maintain the result in a separate custom entity which will help you in maintaining it.

    3)  For memory issue resolution, you can delete the records after 30 days of creation by using a bulk delete workflow/job.

    Please mark the answer as verified if it helps.

    Thank you

    Amit Kumar Rath

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans