How to use `after_action` when soft delete is enabled in global `Change`
Hi, Sorry! I have a global change that i am using inside my many resources! the problem i have when i use soft delete
Ash.destroy!(Ash.get!(MishkaCms.Runtime.Site, id))
it is not triggerd
It does not work
But it works
Is it way to use Archive destroy
inside Ash.Changeset.after_action
?
By the way my config in my resource
I have read this but i am using global Change
- https://hexdocs.pm/ash_archival/0.1.2/archival.html
Thank you in advanceSolution:Jump to solution
So it could be that it uses the
atomic
callback depending on how you call your action and your atomic implementation isn't doing anything. But as your change only has an after_action and that's allowed in the context of atomics you can try this:
```elixir
defmodule MishkaCms.Runtime.Resources.Changes.SendToOban do
use Ash.Resource.Change...11 Replies
global changes don't run on destroy by default - you have to opt in if you want them to do so https://hexdocs.pm/ash/dsl-ash-resource.html#changes-change
eg.
change MyChange, on: [:destroy]
Hi @Rebecca Le , Global change works i can see the print as i say!
the
Ash.Changeset.after_action
dose not run!
for example it works
gotcha, I misunderstood the issue, my apologies
is that the version of AshArchival you're using, 0.1.2? that's quite old, can you try upgrading?
i am using
the last version
Just to make sure, are you returning the modified changeset from your change?
No i just send data to my worker, simple change
Solution
So it could be that it uses the
atomic
callback depending on how you call your action and your atomic implementation isn't doing anything. But as your change only has an after_action and that's allowed in the context of atomics you can try this:
Ammm, but it has error
without chaning atomic before
after_action
ah, yeah it should return
{:ok, changeset}
not {:atomic, changeset}
I updated the example aboveThank you it works, sorry to waste your time
All good, no time wasted. The next person finding this thread will be glad someone asked.