Load latest revision by properties

Created on 9 May 2024, about 2 months ago
Updated 13 June 2024, 13 days ago

Problem/Motivation

I'm integrating Jira with Drupal using ECA and the External Entities module. I'm able to setup a Jira Issue as an entity type in Drupal and connect it to node bundles with entity reference fields. I have a Jira automation that will send a POST request to Drupal on an issue status transition event containing the Jira issue affected. I'd like to load all nodes referencing this issue that have a latest revision in draft, and publish those nodes.

I can almost do this with the Entity: load Action in ECA Content loading by properties but there are two issues:

  1. The entity query used to get entity IDs does not use ->latestRevision. In my case, the Jira issue is referenced on the latest revision draft and not on the current published version (which a current revision is published). This means I cannot load the correct revisions.
  2. Loading by properties will plausibly load multiple entities though this action restricts the result set to 1. This can be worked around by running a while loop of sorts when you update the loaded entities with data that negates from from the initial entity query in future runs.

Steps to reproduce

  • Setup a content type with content moderation workflow.
  • Add a entity reference field to the content type (e.g. taxonomy reference)
  • Create a new node and publish it without an entity reference defined.
  • Create a new draft of the same node and added a entity reference.
  • Setup an ECA endpoint that accepts the entity ID of the referenced entity as an argument
  • Attempt to use the Entity: load Action load an entity by properties where the entity reference field equals the entity ID argument.

Proposed resolution

Should we fix the Entity: load action or is this really a new action to load multiple entities with correct support to load revisions by properties?

Remaining tasks

User interface changes

API changes

Data model changes

πŸ’¬ Support request
Status

Fixed

Version

1.1

Component

Code

Created by

πŸ‡³πŸ‡ΏNew Zealand Josh Waihi

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

Comments & Activities

  • Issue created by @Josh Waihi
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    The "Load Entity" action is deliberately only loading 1 entity, that's why the label is singular. It is meant to be used for simple use cases.

    For scenarios where you want to load multiple entities, we recommend using the views query action instead.

  • Status changed to Fixed about 1 month ago
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    Hope the answer above was sufficient. Please re-open otherwise.

  • Status changed to Active 26 days ago
  • πŸ‡³πŸ‡ΏNew Zealand Josh Waihi

    I am re-opening because the use case (external entities) does not work with views. Entity query is the only way to make this work.

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

    Sorry, what do you mean by "external entities" and what exactly isn't working with views in that case?

    Also, what is "entity query" and how do you get it to work there?

  • Status changed to Closed: works as designed 13 days ago
  • πŸ‡³πŸ‡ΏNew Zealand Josh Waihi

    Re-closing as I was able to take the feedback about using views and apply it. I got a little confused because the External Entities module doesn't allow you to build views with those entity types. However, for my use case, I need a view of nodes referencing a given external entity and I was able to do that and leverage the view in ECA.

  • Status changed to Fixed 13 days ago
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    This is great, thanks for your feedback. I'd like to add that the external entities module seems to be working on views support, though. And in the meantime, there is another module that closes that gap, at least according to the description, I haven't tried it myself.

Production build 0.69.0 2024