How to set the value for the image field

Created on 21 April 2023, over 1 year ago
Updated 26 April 2023, over 1 year ago

I need to copy the first image from field_photos (which can store multiple photos) and save it into field_image filed (this field can store only one image). I'm using 'Presave content entity' event and 'Entity: Set field value' action. I tried different combination for the "Field name" and "Field value": tried using .target_id, .entity, etc. but field_image is always empty.

'Entity: set field value' settings

What is the correct way to do it?

Thank you very much

πŸ’¬ Support request
Status

Fixed

Version

1.1

Component

Documentation

Created by

πŸ‡ΊπŸ‡ΏUzbekistan biarr

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

Comments & Activities

  • Issue created by @biarr
  • πŸ‡ΊπŸ‡ΏUzbekistan biarr
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    So, both fields are entity references, the first one with multi value and the second a single value field. We assume, that both entity reference field are pointing to the same entity type?

    From what I can see in the screenshot, [field_photos:0] is most likely not a valid token. But something like [node:field_photos:0] might be. You should be able to confirm the exact syntax in the token browser, which should be available in the bpmn_io UI when the custom token module is enabled.

    And the debugging techniques described in https://ecaguide.org/eca/debugging/ should in addition to that give you some indication on why an action may not have been executed, if that's the case.

  • πŸ‡ΊπŸ‡ΏUzbekistan biarr

    Thank you for your response. I looked into the log files. No error message. I attached the model, which uses Article content type and two image fields : field_image and field_photos. Model is executed, I'm getting a message and other information I'm checking, but field_image is not populated from the first image of the field_photos.
    Could you look at the model, What am I missing?
    Thank you!

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

    What I can tell from the model is that there is a condition applied top the link between the event and the first action:

    That needs to be removed because it never asserts TRUE. If nothing else helps, delete the link and add a new one without any condition.

    Whether the action is configured correctly, I can't tell because your model doesn't contain the depending config entities. However, fixing the condition may already resolve the issue anyways.

  • πŸ‡ΊπŸ‡ΏUzbekistan biarr

    Thank you @jurgenhaas,
    I deleted the link completely and added a new one without any condition, but that also didn't help.

    I can't tell because your model doesn't contain the depending config entities

    I exported using the export button in ECA and could not find more setting to export the model with dependencies. I can update the many types of the fields including geofield from geolocation. I'm using this module for different complex scenarios. But could not manage do one with images.
    Could it be a bag related to image type of field?

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

    The export finds all the dependencies specified in the ECA model. And they are empty in your example. This might be caused by the site wide ECA settings, where you can select 4 checkboxes, which kind of dependencies should be saved. By default, all 4 of them are on.

  • πŸ‡ΊπŸ‡ΏUzbekistan biarr

    Ohh, thank you for the hint. I'm attaching here the model with dependencies, highly appreciate your help!

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

    Thanks for the updated model. I was able to confirm that it didn't work. I then looked into the token browser to see what kind of tokens are around for the photos field:

    When I used [node:field_photos:0:target_id] in the action, it then worked. This is often the case with tokens, they need some trial and error from time to time.

  • Status changed to Fixed over 1 year ago
  • πŸ‡ΊπŸ‡ΏUzbekistan biarr

    Wow, that solves the problem.
    I was sure that I used all possible combinations with tokens. But mostly I changed the 'Field name' that should be changed, as [node:field_photos:0] brought the first image into the message area.

    Thank you for your kind help and this very powerful module!

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

Production build 0.71.5 2024