I have a website that records my flock of sheep. I have a content type (Sheep Record) with various information about each sheep in it and another content type (Movement Record) to record any movements of sheep on or off the farm.

When I create a Movement record I choose the 'Moved from' and 'Moved to' locations (which are taxonomy terms) and then using Entity Reference and an Entity Reference View Widget, choose which animals are moved.

Currently, I have a field in the Sheep Record for 'Location', which is rendered from a View showing the most recent 'Moved to' field relating to that sheep.

My problem is that this field can't be used to sort the Sheep records by location in other Views etc - as some Sheep have numerous Movement Records referring to them, their Location field is not necessarily unique - I can show the latest 'Moved to' location in the Sheep record using a View, but it is just the latest in the list of Moved to locations referring to that sheep, sorted by date.

I think it should be possible to use Rules to set a field (ie Location) in the Sheep record when a Movement record that refers to that sheep is saved. That is to say, when a Movement record is saved, Rules cycles through all the Sheep records referred to in the Movement record and sets the Location field in each Sheep record to the Moved to field from the Movement record.

Then I would be able to sort the Sheep records by Location.

I have tried to get my ahead around using Rules in this way, but have failed.

Can anyone help me with this?