Answers.Body: <p>As a quick-fix, remove the <code>{action.optOutUrl}</code> token.</p>
  
  <p>To pursue a more general fix, there should be an issue in <a href="http://issues.civicrm.org/" rel="nofollow noreferrer">JIRA</a>. One needs to determine whether:</p>
  
  <ol>
  <li>The <code>{action.optOutUrl}</code> worked in a meaningful way in previous releases. (<em>In this case, we need to define what that was and figure a patch to restore it.</em>)</li>
  <li>Or the <code>{action.optOutUrl}</code> never worked -- and merely became symptomatic in 4.7.16. (<em>In this case, we need to manage the symptom better -- e.g. present a alert to encourage admins to fix their scheduled reminders.</em>)</li>
  </ol>
  
  <p>(If you don't have a JIRA account but can describe the expected behavior, then post a comment here, and I'll try to file it.)</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-02-17T09:13:57.570Z
Answers.Text: Tim.  Thank you for looking at this. I'm not sure I fully understand all what you say but as far as I'm aware, the token {action.optOutUrl} had been working correctly because we have several members who had opted out of bulk emails and their records had been automatically marked as such.  Is it that scheduled reminders don't count as bulk emails and don't need this token?  If you could take this into JIRA, I would be very appreciative.
Answers.UserDisplayName: peterb
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-02-17T18:00:22.227Z
Answers.Text: In my recent experience with trying to use optOutUrl with scheduled reminders, it doesn't work, for the reason Tim moots. It didn't generate errors, they just didn't work, and only after thinking about it did I understand why. I suspect Peter's optouts were coming from other places (e.g. mailouts).
  
  Tim - are you suggesting scanning the scheduled reminders for tokens that will cause issues and generating one of those system status notices? That sounds like a good plan, it could be used to catch other out-of-scope tokens as well.
Answers.UserDisplayName: Alan Dixon
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-02-20T18:56:12.790Z
Answers.Text: (1) Alan: Yes, I think it would be generally good to warn about invalid/out-of-scope tokens.
  
  (2) Peter: Scheduled reminders were originally designed for transactional use (eg "Activity X is coming due") rather than bulk announcements.
  
  (3) Peter: The CiviMail opt-out mechanism was built with tracking behavior -- so you cold see reports about opt-outs. (Ex: "Mailing 123 caused lots of people to opt-out; don't do that again!") However, the details of CiviMail opt-out
  (like mailing_id/queue_id/group_id) don't apply to scheduled reminders.
Answers.UserDisplayName: Tim Otten
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-02-20T19:09:32.373Z
Answers.Text: Based on Alan's comments, I filed in JIRA under formulation 2 -- https://issues.civicrm.org/jira/browse/CRM-20143
Answers.UserDisplayName: Tim Otten
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-02-21T09:35:04.047Z
Answers.Text: Tim.  I deleted the action token {action.optOutUrl} as suggested, but there has been no difference in the error message.  I am still getting "Finished execution of Send Scheduled Reminders with result: Failure, Error message: Error: Cannot use action tokens unless context defines mailingJobId and mailingActionTarget".
  I understand that the tokens {domain.name} and {domain.address} are also action tokens.  Should I delete those as well?
Answers.UserDisplayName: peterb
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-02-22T18:09:54.787Z
Answers.Text: Erg, thanks. Could you test with this patch: https://github.com/civicrm/civicrm-core/pull/9874
Answers.UserDisplayName: Tim Otten
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-02-23T05:10:51.893Z
Answers.Text: Update #9874 with a (hopefully) better patch.
Answers.UserDisplayName: Tim Otten
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-02-17T01:28:44.000Z
Answers.LastActivityDate: 2017-02-17T01:28:44.000Z
Answers.UserDisplayName: Tim Otten
Body: <p>Has anyone experienced problems with running scheduled reminders under civicrm 4.7.16?  After upgrading to that version on 8th Feb and running scheduled reminders for the next issue on 11th February, I got the following error message in the scheduled jobs log:</p>
  
  <p>"Finished execution of Send Scheduled Reminders with result: Failure, Error message: Error: Cannot use action tokens unless context defines mailingJobId and mailingActionTarget"</p>
  
  <p>Scheduled reminders had been running fine until then so I have to assume that there was no problem until v 4.7.16 was installed.
  The action tokens used in the relevant reminder were {contact.first_name}, {membership.type}, {membership.end_date}, a personalised checksum, {domain.address} and {action.optOutUrl}.</p>
  
  <p>I'm not running any civi extensions.</p>
  
  <p>I'm using an up to date version of Wordpress 4.7.2</p>
  
  <p>Any help would be greatly appreciated.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-02-17T01:16:37.337Z
Comments.Text: Question: What's supposed to happen when someone clicks on `{action.optOutUrl}`? What actually happened in the past? In my reading of [the code for optOutUrl](https://github.com/civicrm/civicrm-core/blob/4.7.16/CRM/Mailing/BAO/Mailing.php#L1130), it requires a `job_id` and `event_queue_id`. But those are "Mailing" concepts -- so I don't see how it would have done something sensible for a  "Scheduled Reminder".
Comments.UserDisplayName: Tim Otten
Tags: <wordpress><civimember><scheduled-reminders>
Title: Scheduled Reminders problem in V 4.7.16
ThreadText: # Scheduled Reminders problem in V 4.7.16
  
  (Asked by: username_0 on 2017-02-15)
  
  Has anyone experienced problems with running scheduled reminders under civicrm 4.7.16? After upgrading to that version on 8th Feb and running scheduled reminders for the next issue on 11th February, I got the following error message in the scheduled jobs log:
  
  "Finished execution of Send Scheduled Reminders with result: Failure, Error message: Error: Cannot use action tokens unless context defines mailingJobId and mailingActionTarget"
  
  Scheduled reminders had been running fine until then so I have to assume that there was no problem until v 4.7.16 was installed.
  The action tokens used in the relevant reminder were {contact.first\_name}, {membership.type}, {membership.end\_date}, a personalised checksum, {domain.address} and {action.optOutUrl}.
  
  I'm not running any civi extensions.
  
  I'm using an up to date version of Wordpress 4.7.2
  
  Any help would be greatly appreciated.
  
  **Tags:** wordpress, civimember, scheduled-reminders
  
  > **Comments:**
  > **username_1**: Question: What's supposed to happen when someone clicks on `{action.optOutUrl}`? What actually happened in the past? In my reading of [the code for optOutUrl](https://github.com/civicrm/civicrm-core/blob/4.7.16/CRM/Mailing/BAO/Mailing.php#L1130), it requires a `job_id` and `event_queue_id`. But those are "Mailing" concepts -- so I don't see how it would have done something sensible for a  "Scheduled Reminder".  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-02-17. Score: 2
  
  As a quick-fix, remove the `{action.optOutUrl}` token.
  
  To pursue a more general fix, there should be an issue in [JIRA](http://issues.civicrm.org/). One needs to determine whether:
  
  1. The `{action.optOutUrl}` worked in a meaningful way in previous releases. (*In this case, we need to define what that was and figure a patch to restore it.*)
  2. Or the `{action.optOutUrl}` never worked -- and merely became symptomatic in 4.7.16. (*In this case, we need to manage the symptom better -- e.g. present a alert to encourage admins to fix their scheduled reminders.*)
  
  (If you don't have a JIRA account but can describe the expected behavior, then post a comment here, and I'll try to file it.)
  
  > **Comments:**
  > **username_0**: Tim.  Thank you for looking at this. I'm not sure I fully understand all what you say but as far as I'm aware, the token {action.optOutUrl} had been working correctly because we have several members who had opted out of bulk emails and their records had been automatically marked as such.  Is it that scheduled reminders don't count as bulk emails and don't need this token?  If you could take this into JIRA, I would be very appreciative.  
  > **username_2**: In my recent experience with trying to use optOutUrl with scheduled reminders, it doesn't work, for the reason Tim moots. It didn't generate errors, they just didn't work, and only after thinking about it did I understand why. I suspect Peter's optouts were coming from other places (e.g. mailouts).  Tim - are you suggesting scanning the scheduled reminders for tokens that will cause issues and generating one of those system status notices? That sounds like a good plan, it could be used to catch other out-of-scope tokens as well.  
  > **username_1**: (1) username_2: Yes, I think it would be generally good to warn about invalid/out-of-scope tokens.  (2) Peter: Scheduled reminders were originally designed for transactional use (eg "Activity X is coming due") rather than bulk announcements.  (3) Peter: The CiviMail opt-out mechanism was built with tracking behavior -- so you cold see reports about opt-outs. (Ex: "Mailing 123 caused lots of people to opt-out; don't do that again!") However, the details of CiviMail opt-out (like mailing_id/queue_id/group_id) don't apply to scheduled reminders.  
  > **username_1**: Based on username_2's comments, I filed in JIRA under formulation 2 -- https://issues.civicrm.org/jira/browse/CRM-20143  
  > **username_0**: Tim.  I deleted the action token {action.optOutUrl} as suggested, but there has been no difference in the error message.  I am still getting "Finished execution of Send Scheduled Reminders with result: Failure, Error message: Error: Cannot use action tokens unless context defines mailingJobId and mailingActionTarget". I understand that the tokens {domain.name} and {domain.address} are also action tokens.  Should I delete those as well?  
  > **username_1**: Erg, thanks. Could you test with this patch: https://github.com/civicrm/civicrm-core/pull/9874  
  > **username_1**: Update #9874 with a (hopefully) better patch.  
  
  ---
  
  