Loading entity from Views relationship

Created on 3 April 2023, over 1 year ago
Updated 13 July 2023, over 1 year ago

Problem/Motivation

I am loading a view of contents that are flagged by users (using the Flag module) and the view lists the user UIDs along with the content NIDs thanks to the Flags User relationship. I need to access the list of user IDs but the view token provided in ECA only seems to contain the content entity data and not the related user data.

Proposed resolution

Can the full view including the related entities be accessed in ECA?

πŸ’¬ Support request
Status

Fixed

Version

1.1

Component

Documentation

Created by

πŸ‡ΊπŸ‡ΈUnited States fortran77

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

Comments & Activities

  • Issue created by @fortran77
  • From what I found, Token list in ECA is not completed. You maybe able to find more. In my case, with Views relationship, I can access another related entity using below token.

    [entity:field_name_in_main_content:entity:field_name_in_entity_in_relationship]

  • Issue was unassigned.
  • πŸ‡ΊπŸ‡ΈUnited States fortran77
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    The field relation may not be unique in the use case from @fortran77, in which case you need to create the view such that the returned entities are those that you're interested in from your ECA model. In other words, you seem to be dealing with flag entities, so your view should be selecting those entities, and everything else is only being used as conditions from relationships.

    Note that a view only always returns a list of entities. All the field configurations etc. are later used by view display and format handlers, but that part of a view is not being used by ECA, it only receives the list of entities.

  • πŸ‡ΊπŸ‡ΈUnited States fortran77

    Hello JΓΌrgen, thank you for the help.

    I created a Flagging view and then the flagging user ID shows up in the view (I am printing it to watchdog for debugging purposes).

    However, I don't seem to be able to access the UIDs by token, so eg my view token is named [flagging_subscriber_list] and I can print the full list to watchdog using that token, but if I try to narrow down to the UIDs as [flagging_subscriber_list:uid] then the token is not expanded even though the uid field shows up in the log when I print the full view result.

  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    It sounds like [flagging_subscriber_list] is a list of entities. Sounds like you need to loop over that list where you get one entity per loop in a token of another name, e.g. [flagging]. At that token should then contain the id like probably [flagging:uid].

  • Status changed to Postponed: needs info over 1 year ago
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    @fortran77 any news on this, have you been able to resolve the requirement?

  • Status changed to Fixed over 1 year ago
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    Closing due to missing feedback.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024