0

Here's what I'm trying to do:

  • I have a content type of Question.
  • Questions have a field that identifies their status as "asked" or "answered".
  • Questions marked "asked" can be flagged (using Flag Module) as "follow" by users.
  • When an admin changes the status field of a Question from "asked" to "answered" I would like to flag the Question with an additional flag called "archive" for all the users who "follow" the question.

This is how I set up the rule:

1. Events: After updating existing content

2. Conditions: Entity has field (Parameter: Entity: [node], Field: field_question_status) AND Data Comparison (Parameter: Data to compare: [node:field-question-status], Data value: Answered

3. Actions: Fetch users who have flagged a content (Parameter: Flag: Follow, Content: [node] Provides variables: Users who flagged (users) LOOP (Parameter: List: [users] List item: Current list item (list_item)) ACTION-IN-LOOP Flag a Content (Parameter: Flag: Archive, Content: [node], User on whose behalf to flag: [users:0], Skip permission check: true)

Here's my problem:

The rule seems to be working for only one user at a time. So if 3 users have "followed" a Question and it is switched to "answered" status only one of the users will have the Question flagged as "archive". I found I can specify an individual user in the ACTION-IN-LOOP (action nested in the loop) by changing the value of "User on whose behalf to flag: [users:0]". If I switch the value to users:1 or users:2 then the rule works for those individual users but not all. The only other option I can think of is to try [users] without any additional chained value, but this gives the error "The data type of the configured argument does not match the parameter's flagging_user requirement." How do I get a rule to flag the node (with "archive) on behalf of ALL users who had previously followed it?

1

You need to flag on behalf of the user that the loop is operating with each iteration. Either that or add a numerical variable that you increment each loop and fetch that index from the list of users for the behalf of which to flag

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.