I have a contextual view that lists the last expired Course Session of a teacher.
I use a contextual filter like this:
User: Uid
whereby:
WHEN THE FILTER VALUE IS NOT AVAILABLE
Provide default value Type:
User ID from Logged in user
And
WHEN THE FILTER VALUE IS AVAILABLE OR A DEFAULT IS PROVIDED
Specific validation criteria
Validator: basic validation
Action to take if filter value does not validate: Access Denied
I'm using the Views Rules module and so the Rules Setting configuration is as follows:
Parameters: Edit contextual filter info
Data type: User
Label: Author
Name: uid
Row Variables: Edit field info
ID: Enabled
Data type: Session
Label: Id
Name: id
This regular view and the Rules view both work fine as I am seeing correctly the last value. (Displays only 1 Session)
When I create my rule, upon "Drupal is initializing" I wish to redirect the Teacher to the edit page of this expired Session and set some values but this rule throws an error:
ERROR
The website encountered an unexpected error. Please try again later.
{ "rules_reuse_expired_session_rule" : {
"LABEL" : "Reuse expired Session rule",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"TAGS" : [ "Add a Session", "expired", "reuse", "Session" ],
"REQUIRES" : [ "rules" ],
"ON" : { "init" : [] },
"IF" : [
{ "user_has_role" : {
"account" : [ "site:current-user" ],
"roles" : { "value" : { "11" : "11", "20" : "20", "2" : "2" } }
}
},
{ "text_matches" : { "text" : [ "site:current-page:url" ], "match" : "t\/session\/add" } }
],
"DO" : [
{ "entity_fetch" : {
"USING" : { "type" : "user", "id" : [ "site:current-user:uid" ] },
"PROVIDE" : { "entity_fetched" : { "uid_fetched" : "UID Fetched" } }
}
},
{ "drupal_message" : { "message" : "\u003Ch3 class=\u0022white\u0022\u003EThis is Teacher: UID [uid-fetched:uid]\u003C\/h3\u003E " } },
{ "VIEW LOOP" : {
"VIEW" : "all_my_expired_sessions_teacher",
"DISPLAY" : "views_rules_2",
"USING" : { "uid" : [ "uid-fetched" ] },
"ROW VARIABLES" : { "id" : { "id" : "Id" } },
"DO" : []
}
}
]}}
Does anyone know why I'm getting this error?
If I delete that last action "VIEW LOOP" it works fine, no error and the message shows.
If I use another Rules View without contextual filter, it works fine.