# `Alternera.Resource.Changes.SetReferenceByKey`
[🔗](https://github.com/10e-ab/alternera-sdk/blob/v0.9.0/alternera_resource_sdk/lib/alternera/resource/changes/set_reference_by_key.ex#L1)

On a create or update that accepts a `belongs_to`'s attribute: the
argument `<relationship>_<key>` names the record by its lookup key
(`base_currency_code: "EUR"`) instead of its id, and this change sets the
attribute to that record's id, found in the changeset's tenant as its
actor. A key no record has is an error on the argument; `nil` clears the
reference. Without the argument the attribute is left as it is, so the
id still works (`Transformers.AddReferenceKeys`).

---

*Consult [api-reference.md](api-reference.md) for complete listing*
