I have a Rules Component that I want to run every week, using cron.
The component's elements:
- set a variable (emailbodytext)
- viewsloop 1 to fill the emailbodytext with titles of all recent nodes
- viewsloop 2 to send emails to selected users
When I (as admin) execute the component, it works fine: all selected users receive a mail with the recent node-titles. When I execute thru cron (after planning it) viewsloop 1 always gives zero results, which results in sending empty mails to all selected users in viewsloop 2.
Question:
Why does one view seem to give results and the other does not? Both views have the same access setting (role: adm) in the "Rules setting"-part.
I add the view from viewsloop 1 here:
$view = new view();
$view->name = 'nieuwigheden';
$view->description = 'nieuwe items van de laatste x dagen: blokken om in overzicht op te nemen';
$view->tag = 'default';
$view->base_table = 'node';
$view->human_name = 'Nieuwigheden';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'Nieuwigheden';
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['use_more_text'] = 'meer';
$handler->display->display_options['access']['type'] = 'role';
$handler->display->display_options['access']['role'] = array(
2 => '2',
);
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['exposed_form']['options']['submit_button'] = 'Toepassen';
$handler->display->display_options['exposed_form']['options']['reset_button_label'] = 'Opnieuw instellen';
$handler->display->display_options['exposed_form']['options']['exposed_sorts_label'] = 'Sorteer op';
$handler->display->display_options['exposed_form']['options']['sort_asc_label'] = 'Oplopend';
$handler->display->display_options['exposed_form']['options']['sort_desc_label'] = 'Aflopend';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['pager']['options']['items_per_page'] = '10';
$handler->display->display_options['pager']['options']['expose']['items_per_page_label'] = 'Items per pagina';
$handler->display->display_options['pager']['options']['expose']['items_per_page_options_all_label'] = '- Alle -';
$handler->display->display_options['pager']['options']['tags']['first'] = '« eerste';
$handler->display->display_options['pager']['options']['tags']['previous'] = '‹ vorige';
$handler->display->display_options['pager']['options']['tags']['next'] = 'volgende ›';
$handler->display->display_options['pager']['options']['tags']['last'] = 'laatste »';
$handler->display->display_options['style_plugin'] = 'table';
/* Relatie: Inhoud: Auteur */
$handler->display->display_options['relationships']['uid']['id'] = 'uid';
$handler->display->display_options['relationships']['uid']['table'] = 'node';
$handler->display->display_options['relationships']['uid']['field'] = 'uid';
$handler->display->display_options['relationships']['uid']['required'] = TRUE;
/* Veld: Gebruiker: Naam */
$handler->display->display_options['fields']['name']['id'] = 'name';
$handler->display->display_options['fields']['name']['table'] = 'users';
$handler->display->display_options['fields']['name']['field'] = 'name';
$handler->display->display_options['fields']['name']['relationship'] = 'uid';
/* Veld: Inhoud: Titel */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'node';
$handler->display->display_options['fields']['title']['field'] = 'title';
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE;
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE;
/* Veld: Inhoud: Body */
$handler->display->display_options['fields']['body']['id'] = 'body';
$handler->display->display_options['fields']['body']['table'] = 'field_data_body';
$handler->display->display_options['fields']['body']['field'] = 'body';
$handler->display->display_options['fields']['body']['label'] = 'Berichttekst';
/* Veld: Inhoud: Datum van inzending */
$handler->display->display_options['fields']['created']['id'] = 'created';
$handler->display->display_options['fields']['created']['table'] = 'node';
$handler->display->display_options['fields']['created']['field'] = 'created';
$handler->display->display_options['fields']['created']['label'] = 'Datum';
$handler->display->display_options['fields']['created']['date_format'] = 'datum_zndr_tijd';
$handler->display->display_options['fields']['created']['second_date_format'] = 'long';
/* Veld: Gebruiker: E-mailadres */
$handler->display->display_options['fields']['mail']['id'] = 'mail';
$handler->display->display_options['fields']['mail']['table'] = 'users';
$handler->display->display_options['fields']['mail']['field'] = 'mail';
$handler->display->display_options['fields']['mail']['relationship'] = 'uid';
/* Sorteercriterium: Inhoud: Datum van inzending */
$handler->display->display_options['sorts']['created']['id'] = 'created';
$handler->display->display_options['sorts']['created']['table'] = 'node';
$handler->display->display_options['sorts']['created']['field'] = 'created';
$handler->display->display_options['sorts']['created']['order'] = 'DESC';
/* Filtercriterium: Inhoud: Gepubliceerd */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'node';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['value'] = 1;
$handler->display->display_options['filters']['status']['group'] = 1;
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
/* Filtercriterium: Inhoud: Datum van inzending */
$handler->display->display_options['filters']['created']['id'] = 'created';
$handler->display->display_options['filters']['created']['table'] = 'node';
$handler->display->display_options['filters']['created']['field'] = 'created';
$handler->display->display_options['filters']['created']['operator'] = '>=';
$handler->display->display_options['filters']['created']['value']['value'] = '2017-09-01';
$handler->display->display_options['filters']['created']['group'] = 1;
/* Display: Rules VAB last 7 days */
$handler = $view->new_display('views_rules', 'Rules VAB last 7 days', 'views_rules_1');
$handler->display->display_options['defaults']['access'] = FALSE;
$handler->display->display_options['access']['type'] = 'role';
$handler->display->display_options['access']['role'] = array(
1 => '1',
);
$handler->display->display_options['pager']['type'] = 'some';
$handler->display->display_options['pager']['options']['items_per_page'] = '50';
$handler->display->display_options['pager']['options']['offset'] = '0';
$handler->display->display_options['defaults']['fields'] = FALSE;
/* Veld: Inhoud: Nid */
$handler->display->display_options['fields']['nid']['id'] = 'nid';
$handler->display->display_options['fields']['nid']['table'] = 'node';
$handler->display->display_options['fields']['nid']['field'] = 'nid';
/* Veld: Inhoud: V/A/B */
$handler->display->display_options['fields']['field_v_a_b']['id'] = 'field_v_a_b';
$handler->display->display_options['fields']['field_v_a_b']['table'] = 'field_data_field_v_a_b';
$handler->display->display_options['fields']['field_v_a_b']['field'] = 'field_v_a_b';
$handler->display->display_options['fields']['field_v_a_b']['type'] = 'taxonomy_term_reference_plain';
/* Veld: Inhoud: Titel */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'node';
$handler->display->display_options['fields']['title']['field'] = 'title';
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE;
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE;
/* Veld: Inhoud: Body */
$handler->display->display_options['fields']['body']['id'] = 'body';
$handler->display->display_options['fields']['body']['table'] = 'field_data_body';
$handler->display->display_options['fields']['body']['field'] = 'body';
$handler->display->display_options['fields']['body']['label'] = 'Berichttekst';
/* Veld: Inhoud: Datum van inzending */
$handler->display->display_options['fields']['created']['id'] = 'created';
$handler->display->display_options['fields']['created']['table'] = 'node';
$handler->display->display_options['fields']['created']['field'] = 'created';
$handler->display->display_options['fields']['created']['label'] = 'Datum';
$handler->display->display_options['fields']['created']['date_format'] = 'datum_zndr_tijd';
$handler->display->display_options['fields']['created']['second_date_format'] = 'long';
/* Veld: Gebruiker: Naam */
$handler->display->display_options['fields']['name']['id'] = 'name';
$handler->display->display_options['fields']['name']['table'] = 'users';
$handler->display->display_options['fields']['name']['field'] = 'name';
$handler->display->display_options['fields']['name']['relationship'] = 'uid';
/* Veld: Gebruiker: E-mailadres */
$handler->display->display_options['fields']['mail']['id'] = 'mail';
$handler->display->display_options['fields']['mail']['table'] = 'users';
$handler->display->display_options['fields']['mail']['field'] = 'mail';
$handler->display->display_options['fields']['mail']['relationship'] = 'uid';
/* Veld: Gebruiker: Gemeente */
$handler->display->display_options['fields']['field_p_gemeente']['id'] = 'field_p_gemeente';
$handler->display->display_options['fields']['field_p_gemeente']['table'] = 'field_data_field_p_gemeente';
$handler->display->display_options['fields']['field_p_gemeente']['field'] = 'field_p_gemeente';
$handler->display->display_options['fields']['field_p_gemeente']['relationship'] = 'uid';
$handler->display->display_options['fields']['field_p_gemeente']['type'] = 'text_plain';
$handler->display->display_options['defaults']['filter_groups'] = FALSE;
$handler->display->display_options['defaults']['filters'] = FALSE;
/* Filtercriterium: Inhoud: Gepubliceerd */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'node';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['value'] = 1;
$handler->display->display_options['filters']['status']['group'] = 1;
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
/* Filtercriterium: Inhoud: Datum van inzending */
$handler->display->display_options['filters']['created']['id'] = 'created';
$handler->display->display_options['filters']['created']['table'] = 'node';
$handler->display->display_options['filters']['created']['field'] = 'created';
$handler->display->display_options['filters']['created']['operator'] = '>=';
$handler->display->display_options['filters']['created']['value']['value'] = '-8 days';
$handler->display->display_options['filters']['created']['value']['type'] = 'offset';
$handler->display->display_options['filters']['created']['group'] = 1;
/* Filtercriterium: Inhoud: Type */
$handler->display->display_options['filters']['type']['id'] = 'type';
$handler->display->display_options['filters']['type']['table'] = 'node';
$handler->display->display_options['filters']['type']['field'] = 'type';
$handler->display->display_options['filters']['type']['value'] = array(
'vraag_of_aanbod' => 'vraag_of_aanbod',
);
$handler->display->display_options['rules_variables'] = array(
'nid' => array(
'enabled' => 1,
'rendered' => 0,
'type' => 'integer',
'label' => 'Nid',
'name' => 'nid',
),
'field_v_a_b' => array(
'enabled' => 1,
'rendered' => 1,
'type' => 'text',
'label' => 'V/A/B',
'name' => 'field_v_a_b',
),
'title' => array(
'enabled' => 1,
'rendered' => 0,
'type' => 'text',
'label' => 'Titel',
'name' => 'title',
),
'body' => array(
'enabled' => 1,
'rendered' => 1,
'type' => 'text',
'label' => 'Berichttekst',
'name' => 'body',
),
'created' => array(
'enabled' => 1,
'rendered' => 0,
'type' => 'date',
'label' => 'Datum',
'name' => 'created',
),
'name' => array(
'enabled' => 1,
'rendered' => 0,
'type' => 'text',
'label' => '(auteur) Naam',
'name' => 'name',
),
'mail' => array(
'enabled' => 1,
'rendered' => 0,
'type' => 'text',
'label' => '(auteur) E-mailadres',
'name' => 'mail',
),
'field_p_gemeente' => array(
'enabled' => 1,
'rendered' => 1,
'type' => 'text',
'label' => '(auteur) Gemeente',
'name' => 'field_p_gemeente',
),
);
$translatables['nieuwigheden'] = array(
t('Master'),
t('Nieuwigheden'),
t('meer'),
t('Toepassen'),
t('Opnieuw instellen'),
t('Sorteer op'),
t('Oplopend'),
t('Aflopend'),
t('Items per pagina'),
t('- Alle -'),
t('Offset'),
t('« eerste'),
t('‹ vorige'),
t('volgende ›'),
t('laatste »'),
t('auteur'),
t('Naam'),
t('Titel'),
t('Berichttekst'),
t('Datum'),
t('E-mailadres'),
t('Rules VAB last 7 days'),
t('Nid'),
t('V/A/B'),
t('Gemeente'),
);
And the rules itself: a duplicate where I replaced viewsloop2 with only 1 emailaddress:
{ "rules_weekoverzicht_per_mail_gedupliceerd_" : {
"LABEL" : "Weekoverzicht per mail (gedupliceerd)",
"PLUGIN" : "action set",
"OWNER" : "rules",
"TAGS" : [ "mail" ],
"REQUIRES" : [ "rules" ],
"ACTION SET" : [
{ "variable_add" : {
"USING" : {
"type" : "text",
"value" : "\u003Ch2\u003E[site:name] weekoverzicht op [site:current-date]\u003C\/h2\u003E\r\n"
},
"PROVIDE" : { "variable_added" : { "variable_samengesteld" : "Samengestelde inhoud" } }
}
},
{ "drupal_message" : { "message" : "[mail-from-view:value]" } },
{ "data_set" : {
"data" : [ "variable-samengesteld" ],
"value" : "\u003Cp\u003EDag\u003C\/p\u003E\r\n\u003Cp\u003ETer herinnering: Om de \u0022mail alle leden - nieuwe stijl\u0022 te ontvangen moet je in \u0022Mijn account: Adres etc bewerken\u0022 aanduiden tot welke interessegroep je behoort. Pas daarna ontvang je direct een email wanneer een nieuwe V\/A gepost wordt in jouw interesse. \u003C\/p\u003E\r\n\u003Cp\u003EHet volautomatische weekoverzicht woensdagnacht was niet echt een succes. Volgende keer beter.\r\n\u003C\/p\u003E\r\n\r\n[variable-samengesteld:value]"
}
},
{ "mail" : {
"to" : "[email protected]",
"subject" : "[[site:name]] Weekoverzicht test",
"message" : [ "variable-samengesteld" ],
"language" : [ "" ]
}
},
{ "VIEW LOOP" : {
"VIEW" : "nieuwigheden",
"DISPLAY" : "views_rules_1",
"ROW VARIABLES" : {
"nid" : { "fiche_nid" : "Nid van VAB fiche" },
"field_v_a_b" : { "fiche_field_v_a_b" : "V\/A\/B uit view" },
"title" : { "fiche_title" : "Titel uit view" },
"body" : { "fiche_body" : "Body uit view" },
"created" : { "fiche_created" : "Datum creatie" },
"name" : { "fiche_van_name" : "(auteur) Naam" },
"mail" : { "fiche_van_mail" : "(auteur) E-mailadres" },
"field_p_gemeente" : { "fiche_field_p_gemeente" : "(auteur) Gemeente" }
},
"DO" : [
{ "data_set" : {
"data" : [ "variable-samengesteld" ],
"value" : "[variable-samengesteld:value]\r\n\u003Chr\u003E\r\n\u003Ch3\u003E\u003Ca href=\u0022[site:url]\/node\/[fiche-nid:value]\u0022\u003E [fiche-title:value]\u003C\/a\u003E\u003C\/h3\u003E\r\n\u003Cp\u003E\u003Cstrong\u003E[fiche-field-v-a-b:value] van [fiche-van-name:value] ([fiche-field-p-gemeente:value]) dd. [fiche-created:value]\u003C\/strong\u003E\u003C\/p\u003E\r\n\u003Cp\u003E[fiche-body:value]\u003C\/p\u003E\r\n\u003Cp\u003E Antwoorden via \u003Ca href=\u0022mailto:[fiche-van-mail:value]\u0022\u003E[fiche-van-mail:value]\u003C\/a\u003E\u003C\/p\u003E\r\n\r\n"
}
}
]
}
},
{ "data_set" : {
"data" : [ "variable-samengesteld" ],
"value" : "[variable-samengesteld:value]\r\n\u003Chr\u003E\r\n\u003Cp\u003EDe Letsleie Robot\u003C\/p\u003E\r\n\u003Cp\u003EJe krijgt deze mail omdat je lid bent van Letsleie. Via \u0022Mijn account: Adres etc. bewerken\u0022 kun je aanduiden of je wel of niet een wekelijks overzicht per email wenst.\u003C\/p\u003E "
}
},
{ "drupal_message" : { "message" : "[variable-samengesteld:value]" } },
{ "mail" : {
"to" : "[email protected]",
"subject" : "weekoverzicht test",
"message" : [ "variable-samengesteld" ],
"language" : [ "" ]
}
}
]
}
}
When executed from UI I receive a mail with the introduction text and the node-info. When exectuded thru cron the mail only has the introduction text.