3

I'm building a submission-review page where submitters select a reviewer. Submissions show up on reviewers profile page and have accept and decline buttons implemented with Button Field module. When the reviewer clicks the accept button, he gets redirected to a new review content form.

Review content type has a node reference field to submission content type which should get populated automatically using Node Reference URL Widget.

I use the Rules module to check if accept button has been clicked and to fire the Page redirect action:

defined rule

After defining condition Entity is of type Node replacement patterns show up and seem to be available:

replacement patterns

So I fill URL to redirect to with the relative url and the entity id:

node/add/review/[entity:nid]

But it doesn't have effect. Rule gets fired correctly but [entity:nid] is empty and reviewer gets redirected to node/add/review/ and so node id to prepopulate node reference field is not available.

Am I doing something wrong or is it a bug in Button Field? Any hints to implement that funcionality in a different way?

2

I'm not familiar with using the Button Field module in combination with the Rules module.

But from your question details, it seems that the entity:nid value is indeed blank. A possible solution is typically to add a Rules Action which is either of these:

  • "Fetch entity by ID" (if you know the ID you're processing).
  • "Fetch entity by Property" (if you have some criteria to build a list of things to be processed in a subsequent Rules Loop).

Especially the "Fetch entity by ID" is what I think you should give it a try. Also because of what's written in Comment nr 3 of issue nr 1796952, and which has some pseudo code like so:

  • event : on User clicks a button field
  • condition: Entity is of type on entity (make sure everything is in scope of rule)
  • actions:
    • Fetch entity by id with ID (data selector) : entity:nid
    • pump the 'fetched entity' into a component and do things in there

If none of the above helps, then the "Submissions show up on reviewers profile page" part of your question is something that may help to use a completely different approach. If that's something like a Views result" (is it?), then you could maybe use either of these approaches:

  • Add a Rules Action to load a list the list of results created via a VBO enabled view.
  • Use the Views Rules module to have each row of that view processed via Rules, whereas you can make each column of such view available as a rules token, so if that "nid" is included in it, you have what you're looking for.

If none of the above help, You may want to use Rules debugging (eg to display values of relevant things using the Devel module, so that you can (temporary) add a Rules Action like "Display a value". For more suggestions about that, refer to "How can I display the value of a variable inside a condition?".

PS: those 2 AND Rules Conditions are not needed in your case (that's the default of how Rules combines multiole Rules Conditions).

| improve this answer | |
  • Thanks for your well elaborated answer. I added a "Fetch entity by ID" action and afterwards node id is available to be used in my Page redirect action. Still I don't get the point why entity:nid is available to the "Fetch entity by ID" action but not directly to "Page redirect" action. But most important, your proposed solution works. Thanks! – geraldo Feb 18 '17 at 21:16
  • @geraldo merci for the accept (and +1). Actually I was pretty sure about that "Fetch entity by ID", but a confirmation about it is appreciated even more of course. About that entity-nid token being shown (but with no value): that's right now a bit of a mystery to me too. I might do some more experiments (using rules debugging tricks), to get more details on that. If I do figure it out, I'll drop you another comment around here. – Pierre.Vriens Feb 18 '17 at 21:26

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.