Hi,

We have a requirement for a global flag but tracking the user who flagged. To do this, we set up a global flag and added an entity reference field to it.

To get it to work, we tried setting up a rule to be fired on flagging. However, it seems to have multiple issues.

Firstly, I needed to add a condition - flagging is of bundle . This fails with the following

Call to undefined method stdClass::type()

I was able to work around this by calling entity_metadata_wrapper on the flagging object before passing it to rules. However, the bundle check fails for reasons unknown.

As a workaround, I changed to check to "entity has field ". This check passes correctly.

I need one of the above checks before Drupal will let me call the "Set data value" action on flagging:

However, when I have set the action to set flagging: to site:current_user, it fails with the following (from rules debug)

22.377 ms Unable to apply data selector flagging:field-user. The specified variable is not a list or a structure: Property .
22.527 ms Unable to evaluate action data_set. [edit]
23.089 ms Evaluating the action entity_save. [edit]
23.335 ms Rule Inaccurate Flagging has fired.

Is there a way to work around this? I am happy to dig through code and apply a fix if you can point me in the right direction.

Thanks...

Comments

joachim’s picture

Could you file a separate bug for the problem with getting the type of the flag please? That's definitely something that ought to be doable!

What you're trying to accomplish would be easier done with this: #2087797: Record uid for global flags.

drone.ah’s picture

Thanks for the swift response.

I have created a new item: #2214813 Rules integration for Flagging is of bundle and am looking at #2087797...

apmsooner’s picture

Status: Active » Closed (duplicate)
Parent issue: » #2269391: Add rules action to fetch flagging by user for a particular entity

See feature request that should resolve this issue: https://www.drupal.org/node/2269391