with_variables function

A helper function to set variables that the record is dependent on.