Hi all,

I have a problem which I do not get solved. After some researching it seems that some others have the same problem but I found no solution.

My aim is to fetch an entity by ID... To be able to use rules' data selector in action "Fetch entity by ID" I added an action "Add a variable" before which should get the nid by a custom PHP code. Here I want to get this nid by views_get_view_result() where I need some variables from the rules (for example $node, $user1 and $user2 -> so the whole thing looks like

$node_id = views_get_view_result('name_of_the_view','master', $user1->uid, $node->nid, $user2->uid);

But when I use these variables ($node, $user1, $user2) which I can use in any PHP code action without any problem I get these error messages (one as an example):

Notice: Undefined variable: node in eval() (line 1 of C:\wamp\www\website\sites\all\modules\rules\modules\php.eval.inc(146) : eval()'d code).
Notice: Trying to get property of non-object in eval() (line 1 of C:\wamp\www\website\sites\all\modules\rules\modules\php.eval.inc(146) : eval()'d code).

So now my question is: how can I use the variables of my rules to run this view function in order to get the nid I need???? Or is there anothyer way? Could I set a new variable in rules by PHP Code? I tried "intelligent saving": add variable, run custom PHP code to get the id by the view function and then return $my_node; where "$my_node" is the name of the variable set in rules action... this did not work as well.

I would highly appreciate any suggestion how I could solve this problem.

Best,
Tobias

Comments

bander2’s picture

Tobias,

Can you post the rule?

tr’s picture

Status: Active » Closed (works as designed)

Original poster never provided the requested information, and never followed up. Assuming the issue was resolved.