How to access map keys in arg

I have an action like below where the accepted argument is a map


  actions do
    create :generate_session_token do
      argument :user, :map
    end
  end

Assuming argument :user map has an :id key, how do I access it inside the set_attribute? Obviously the following won’t work because arg(:user) gets expanded to a tuple {:_arg, :user} and I can’t get the :id field here.

      change set_attribute(:user_id, arg(:user).id) # Wont work

You will need to use a custom change for this.

change fn changeset, _ -> 
  Ash.Changeset.force_change_attribute(changeset, :user_id, changeset.arguments.user.id)
end