- Issue created by @senzaesclusiva
- 🇩🇪Germany jurgenhaas Gottmadingen
It depends, where the information is being stored and how one could find out, if a certain entity had already been created or not.
Let's assume, the user entity had an entity reference field to that other entity, you could use a condition to check if that field in the user entity is empty or not. If it's empty, the user hasn't created one and you can do your magic then.
- 🇮🇹Italy senzaesclusiva
Thank you for your response
The data is all stored in the default DB. Indeed, an empty field referring to the user type should indicate that I have not yet created any of its nodes.
In Rules D7 I used to realize this condition thanks to a PHP plugin that allowed me to run a query on the DBglobal $user; $result = db_query("SELECT nid FROM node JOIN users ON node.uid = users.uid WHERE node.status = :status AND users.uid = :uid AND node.type = :type", array(":status"=> 1, ":uid" => $user->uid, ":type" => 'professional'))->fetchField(); if ($result >= 1){ return FALSE; } else{ return TRUE; }
If the result returned TRUE the action was executed.
I will try what you suggested
Thanks again - 🇩🇪Germany jurgenhaas Gottmadingen
Well, writing PHP in the front end is the most UNSAFE feature one can think of and ECA will never add support for anything like that.
However, with ECA you can run a view, so you can build the SQL query that way. Then you can check if that view returned 1 or no record. That's pretty much the same.
Still, if I were in your shoes, I'd go for a (invisible) entity reference field from the user entity to the created node. That's much more performant and easier to work with. It probably will provide more benefits down the road as well.
- 🇮🇹Italy senzaesclusiva
I know, but "back then" it was used :-)
Great if ECA can use views!
Thanks also for the suggestion of the hidden field...hadn't thought of that, sic!
Thanks again - Status changed to Fixed
10 months ago 4:21pm 21 February 2024 - 🇩🇪Germany jurgenhaas Gottmadingen
Assuming this is fixed, please feel free to re-open if not.
Automatically closed - issue fixed for 2 weeks with no activity.