Changing field value of entity reference from a list results in the original list being incorrectly changed

Created on 6 May 2023, about 1 year ago
Updated 8 May 2023, about 1 year ago

Problem/Motivation

A node has a list of entity references (users). When edit or save the node, the entity references (users) in the list should have a field updated with the NID of the edited/saved node. Very easy to do with 1 user but when I start looping there are issues.

When one of my ECA models (attached) run, they do update the user field with the NID but it also changes the original list from the node. Clearly the intent is not to do this.

Say the list has 3 entities:

  1. User 1
  2. User 2
  3. User 3

When one of the models run, this is how it changes the list:

  1. User 3
  2. User 2
  3. User 3

Steps to reproduce

  1. Create a content type with an entity reference (users) field
  2. Add a text field to the account settings of users
  3. Add a node with a few users
  4. Run one of t

he attached models here (editing the field/token settings to match your environment)

Following this guide: https://ecaguide.org/library/use%20case/multi_value_field_loop/
I created a number of models to get this to work. I attach 2 that both create the same issue as described above.

Proposed resolution

Attached also is an old Rules action from a Drupal 7 site that does exactly what I'm trying to do here.

Perhaps this is a bug or perhaps grappling with this simple task for 24 hours I'm a bit lost!

Great work on this exciting module. TIA for any help.

πŸ’¬ Support request
Status

Fixed

Version

1.1

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom mrcharles

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024