1

I am trying to use a view which depends on arguments but somehow it seems that the arguments are not passed to the view since I am getting no results. The view works when executed directly. The rule is triggered by Cron. Does Cron require any special permission to access the view? Any other ideas on solving this would be much appreciated

Rules is version 7.x-2.10 Views is version 7.x-3.16 Views Bulk Operation is 7.x-3.4+13-dev

{ "rules_send_reminder_1" : {
"LABEL" : "Send Reminder 1",
"PLUGIN" : "reaction rule",
"ACTIVE" : false,
"OWNER" : "rules",
"TAGS" : [ "Reminder" ],
"REQUIRES" : [ "rules", "views_bulk_operations" ],
"ON" : { "cron" : [] },
"DO" : [
  { "data_calc" : {
      "USING" : { "input_1" : [ "site:current-date" ], "op" : "+", "input_2" : 7776000 },
      "PROVIDE" : { "result" : { "result" : "Calculation result" } }
    }
  },
  { "drupal_message" : { "message" : "Fetching licenses that expire \u003C [result:value] and with status = 1" } },
  { "views_bulk_operations_action_load_list" : {
      "USING" : { "view" : "licence_reminder|default", "args" : "[result:value]\r\n1" },
      "PROVIDE" : { "entity_list" : { "entity_list" : "A list of entities" } }
    }
  },
  { "LOOP" : {
      "USING" : { "list" : [ "entity-list" ] },
      "ITEM" : { "list_item" : "Current list item" },
      "DO" : [
        { "drupal_message" : { "message" : "Processing licence with id : [list-item:license-id]" } },
        { "component_rules_reminder_1" : { "license" : [ "list-item" ], "status" : "1" } }
      ]
    }
  }
]
}
}

Note: I am hoping to find users that hold an expiring license, and that have been issued a new invoice which remains unpaid with the view (each user holds a status that indicates if the invoice has been issued and if it is paid or not). Then I will send the user a reminder email.

1
  • Sorry if the question is unclear. I am hoping to find users that hold an expiring license, and that have been issued a new invoice which remains unpaid with the view (each user holds a status that indicates if the invoice has been issued and if it is paid or not). Then I will send the user a reminder email. Any suggestions on how to accomplish this would be much appreciated.
    – Bosse
    Commented Aug 8, 2017 at 7:20

1 Answer 1

1

I think you're making it too complicated. As per the "Any other ideas on solving this would be much appreciated ..." in your question, I'd rather use the Views Rules module (instead of VBO), as further detailed below.

1. About the Views Rules module

The Views Rules module makes Views data available in Rules, enabling intuitive rule configuration for dynamic data. Some details from its project page:

... provides two types of elements in Rules, configured with a "Rules" view display:

  • Views loop: A views loop is similar to a regular Rules loop, but allows looping over rows of view results.

    enter image description here

  • Collect view result rows (action): This action collects each variable in all view result rows into list variables for use in Rules.

Tip: When selecting the data type for variables in the view, if the field is an entity identifier (e.g. Node ID), you can set the data type to the entity type (i.e. Node) to directly use the variable in Rules as an entity!

2. Create a view of display type 'Rules'

After you enable the Views Rules module, you can use Views to create a view of the users you're interested in. I.e. "those users that hold an expiring license, and that have been issued a new invoice which remains unpaid" (as in your question). Add of view of display type Rules (important, that's the key to make it work!). Here is how you can add such display:

enter image description here

Next configure the row variables, by using the link that says "edit field info", as shown here:

enter image description here

You probably want to use one or more of the variables similar to those that are shown in this screenprint:

enter image description here

3. Create a rule using the view of display type 'Rules'

Create a rule with the appropriate Rules Actions in it, using these guidelines:

  • Use the link that says Add view loop to add a Views loop, and select the "Rules" display created in the previous step.
  • Configure the parameters and variable names.
  • For each user contained in your Views loop, perform whatever Rules Action that fits your requirement, using the variables you configured at the end of the previous step (you may have to revisit the previous step to add more similar variables there if needed). If you created the Rules row variables as suggested in the previous step, your actual eMail can use tokens such as [usermail:value], [username:value], etc.

4. Use the 'Rules Once per Day' module

Use the "Rules Once per Day" module. Here is how it works (as per the comment in issue 2495775, from the module owner):

  • You specify a trigger hour on the administration settings page for this module.
  • The Rule trigger will then run when cron tasks are first run after the start of that hour. The actual run time will depend on your cron task timings.

So this is another way to understand/Read this:

  • The "Event" will only be triggered when a cron job is run.
  • And that event will only be triggered 1 time / day, i.e. "next time cron runs after the trigger hour has passed".

Easy, no?

2
  • Works great as described.
    – Bosse
    Commented Aug 13, 2017 at 20:39
  • Merci for the confirmation, may I say "what else did you expect?" ... A,d merci for the accept ! Next question? Commented Aug 13, 2017 at 20:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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