Current section

Files

Jump to
ash_oban usage-rules triggering_jobs_programmatically.md
Raw

usage-rules/triggering_jobs_programmatically.md

<!--
SPDX-FileCopyrightText: 2020 Zach Daniel
SPDX-License-Identifier: MIT
-->
# Triggering Jobs Programmatically
You can trigger jobs programmatically using `run_oban_trigger` in your actions:
```elixir
update :process_item do
accept [:item_id]
change set_attribute(:processing, true)
change run_oban_trigger(:process_data)
end
```
Or directly using the AshOban API:
```elixir
# Run a trigger for a specific record
AshOban.run_trigger(record, :process_data)
# Run a trigger for multiple records
AshOban.run_triggers(records, :process_data)
# Schedule a trigger or scheduled action
AshOban.schedule(MyApp.Resource, :process_data, actor: current_user)
```