- Issue created by @biarr
- 🇩🇪Germany jurgenhaas Gottmadingen
Triggering the custom event forwards 2 entities: the implicit
entity
from the views loop, and the explicitoriginalentity
. So, those are the 2 entities that are known to your custom event and its succeeding actions.When you use the "Set field value" action, you're using a token named
node
, that doesn't exist. Also, in that action, you're not telling which entity should get the field set. So, at the very bottom, you need to tell the action that you want to useoriginalentity
to be used as that entity. Thinking again, maybe you want to set the field inentity
? Then you can provide that token name but you don't have to, because it's the default.Last but not least, if setting the field value, that's not enough. You also need to save the entity. You can either enable that in that action or add another one to just save the entity.
Now, your 2 starting events are "insert" and "pre-save". For a new entity, that will trigger twice. In the labels, you're using "New" and "Update", but that's not what your events are doing. The "insert" event is what you get for "New", but the "pre-save" event triggers every time an entity gets saved.
And that leads to yet another problem: recursion. You may want to build some prevention into your model so that it doesn't try to run in circles.
- 🇺🇿Uzbekistan biarr
Hi @jurgenhaas, thanks a lot for your detailed explanation—it's very helpful!
It's especially important for me to know that the entity forwarded from the Views result is called `entity`. That clarification alone clears up a lot!
My main goal is to update a reference field in `originalentity` with the entity selected in the Views result.
Here’s what I’ve tried:
- If I set the field value directly in the first event (without calling the custom event), it works perfectly—the reference is saved.
- But when I move the logic into a Custom event, it stops working entirely.
- I even hardcoded the reference using a known NID (9970), but still no effect.
- I’ve tried both enabling "Save entity" in the "Set field value" action and adding a separate "Entity: Save" action afterwards—still no success.
- I simplified things by keeping only the Presave event as the trigger.
Despite all this, the custom event just doesn’t update the field in `originalentity`. Could it be that the context or saving logic is not correctly bound inside the custom event? Or maybe there's an issue with recursion or how the event chain is executed?
At this point, I wonder—could this be a bug or am I still missing some very simple thing?
Thanks again for your help, and I’d appreciate any further thoughts or ideas!
- 🇺🇿Uzbekistan biarr
Just a quick update—I ran further tests by trying to set a simple integer field in the Custom event, using
originalentity
in the "Entity to operate on" section at the very bottom of the action.This action uses only the
originalentity
token directly, without any other tokens or logic.Still, the model doesn’t update any value at all.
At this point, I genuinely don’t understand what I might be doing wrong. Even this minimal case fails, so I feel like I'm either missing a critical detail—or something isn’t functioning as expected.
Any insight would be very much appreciated!
- 🇩🇪Germany jurgenhaas Gottmadingen
Have you tried the debugging which is described at Debugging? This will tell you what's going on, e.g. if there's an access issue or tokens don't have the expected content.
- 🇺🇿Uzbekistan biarr
Thank you with this debug hint. I found the issue — my fault after all. Debugging revealed it was an access problem.
I added an explicit "Switch user" action at the beginning of the model to run as user 1, and after that, the model finally started saving the reference correctly.
What’s interesting is that I was already running the model as user 1, and I had even selected user 1 in the "Execute models with user" setting. But that alone wasn't enough.
Only after explicitly adding the Switch user action did it actually work.
A bit unexpected, but at least I know where the problem was now. Hope this helps someone else too.
- 🇩🇪Germany jurgenhaas Gottmadingen
Thanks for your feedback, great this is now resolved.