Page MenuHomePhabricator

Make Civi Reminders work in Staging
Closed, ResolvedPublic2 Estimated Story Points

Description

There is a feature in Civi where you can set a reminder to follow up with a contact at some date in the future. Currently, you can set everything up but it does not actually remind anywhere.

Make reminders work - we should figure out how this will "remind" before going forward.

Event Timeline

atgo raised the priority of this task from to Medium.
atgo updated the task description. (Show Details)
atgo added subscribers: Aklapper, atgo, RLewis.

I tried running this job and got:
Finished execution of Scheduled reminders sender with result: Failure, Error message: DB Error: syntax error

and also,

02:35:43 Undefined index: ActionSchedule.php:760 [notice]
02:35:43 Undefined variable: contactField ActionSchedule.php:851 [notice]
02:35:43 Undefined variable: contactField ActionSchedule.php:859 [notice]
02:35:43 Undefined variable: contactField ActionSchedule.php:863 [notice]
02:35:43 Undefined variable: contactField ActionSchedule.php:868 [notice]

Found and deleted a malformed test reminder which was throwing these errors. It had a null recipient, and... the Civi logic does not check for that.

I tried to create another reminder, but found I could not add myself as a manual recipient. The UI is really funky.

Now I've added myself to a test group, and left things enabled to in theory remind myself about foo tomorrow.

atgo renamed this task from Make Civi Reminders work to [BUG] Make Civi Reminders work.Feb 4 2015, 9:09 PM

It's still failing with a DB syntax error, probably the same reason, that the recipient is empty.

atgo raised the priority of this task from Medium to High.EditedFeb 6 2015, 7:06 PM

Major Gifts wants to use Civi Grants, and reminders are a key part of this. Increasing priority

atgo renamed this task from [BUG] Make Civi Reminders work to Make Civi Reminders work.Feb 12 2015, 7:10 PM

@CaitVirtue, @RLewis, could you please add some detail about how you want to use reminders? Do you want them triggered by events or by Civi activities, and who do you want to get them?

CiviCRM isn't coded right some reminder configurations, such as choosing a group with activity-related reminders. Other configurations work fine: for instance, you can get an activity-related reminder sent to the activity's assignees, source, or targets.

Running the send_reminders job from the commandline:

drush --user=1 -v civicrm-api job.send_reminder auth=0 -y

Nice errors,

Undefined index:  ActionSchedule.php:760                                                                   [notice]
Undefined variable: contactField ActionSchedule.php:851                                                    [notice]
Undefined variable: contactField ActionSchedule.php:859                                                    [notice]
Undefined variable: contactField ActionSchedule.php:863                                                    [notice]
Undefined variable: contactField ActionSchedule.php:868                                                    [notice]
Array
(
    [is_error] => 1
    [error_message] => DB Error: syntax error
    [debuginfo] => "\nINSERT INTO civicrm_action_log (contact_id, entity_id, entity_table, action_schedule_id)\nSELECT  as contact_id, e.id as entity_id, 'civicrm_activity' as entity_table, 2 as action_schedule_id\nFROM civicrm_activity e\nINNER JOIN civicrm_group_contact grp ON  = grp.contact_id AND grp.status = 'Added' INNER JOIN civicrm_contact c ON c.id =  AND c.is_deleted = 0 AND c.is_deceased = 0 \nLEFT JOIN civicrm_action_log reminder ON reminder.contact_id =  AND\nreminder.entity_id          = e.id AND\nreminder.entity_table       = 'civicrm_activity' AND\nreminder.action_schedule_id = 2\nWHERE e.activity_type_id IN (28) AND e.status_id IN (2) AND  e.is_current_revision = 1  AND  e.is_deleted = 0  AND grp.group_id IN (267) AND reminder.id IS NULL AND DATEDIFF(DATE('20150219121111'),'2015-01-30') = 0  [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'as contact_id, e.id as entity_id, 'civicrm_activity' as entity_table, 2 as actio' at line 3]"
    [tip] => add debug=1 to your API call to have more info about the error
)

Yeah, choosing a group as a recipient is totally fubared (in 4.2, at least). For activity-based reminders, that undefined contactField produces the malformed join to the group contact table you can see in that log. For event-based reminders, it seems that the group acts as a filter on recipients, so you have to both be an event contact AND be in the group to get it. This is in CRM_Core_BAO_ActionSchedule::buildRecipientContacts.

The manual recipient entry calls /ajax/checkemail and gets results, but for some reason name = null on all of them.

Trunk code is fairly different from 4.2 and includes a 'limit to' option which would seem to control whether the group is a filter or just a list. I can peek at 4.4, but I thought it would be worth asking for the specific use cases we need to support first.

@Ejegg, @awight and @CaitVirtue we want reminders to be used under Activities. For example, we'd like to set reminders for myself to follow up with donors/contacts. I'd also like to set a reminder for Caitlin and other Civi users for example if they need to email a donor on a specific date etc. As mentioned earlier on in the thread, since this has never worked we're not entirely sure how the reminders would actually remind us.

Thanks for the info! That might work, possibly with a new custom activity type like 'should email'. I imagine the donor would be the activity target and the Civi user would be the assignee. I'll test some possibilities locally to see if we can generate an email to the assignee that has includes enough information about the target contact to be useful.

@Ejegg, thanks for the valuable though sad details! I'm playing with the "Reminder" activity type on staging, and I've created a new scheduled reminder which should email on the date set in the activity.

Looks like there are many issues however. The next big obstacle is that the autocomplete fields for activity "with" (wtf?) and "assigned to" don't work.

@awight you put this up for grabs.... @Ejegg are you owning it?

@atgo: I think @Ejegg pretty much nailed the coffin shut. I'm ready to set this as blocked until the CiviCRM 4.4 upgrade... The reminder code is in really bad shape, we could probably whip something up in a couple of days, but I'm allergic to touching the 4.2 core code any more than we absolutely have to.

Brilliant work! I just received a reminder. There's more followup to do, tech and admins need to talk about the reminder activity type, when the reminders should be sent, whether reminders are automatically sent for several activity types, or if they are their own type of activity...

So far, I've set up reminders on the staging server to send an email at the time specified in a Reminder activity. The assignee received the email. The email contents are just the activity subject, and the "with" contact.

@awight wow, great stuff. Can we discuss this in our MGF meeting tomorrow?

Maybe even re-use the 'Emailed' activity type - reminders get sent a day before for those in 'scheduled' status, and when you've actually emailed the contact you can update the status to completed and optionally put the text in the activity details.

I'm not sure we're getting any of the 'with'/target contact details in the email (it looks like the tokens are all coming from the assignee), but we can at least get the activity ID and include a link to the activity in civi.

@RLewis, good idea! If KBrownell is still available, we should ask her to explain best practices for reminders...

@Ejegg: You're right, those were assignee details included in my reminder to self. You didn't receive anything, did you? You were the unhappy target of the activity ;)

Another strange thing, I got two emails a minute apart. The first was spoofed a From myself, and the body was the custom template configured in "Scheduled Reminders". The second was sent by the default From address (donate@wmo), and contained a table view summarizing the activity, including links to edit and view the activity.

Sorry to be late to the party here...

@Ejegg @awight We also have wild hopes and dreams of having the reminders work in conjunction with CiviGrant too, to remind us of things like grant reporting deadlines, and scheduled announcements of new funding opportunities.

@RLewis @CaitVirtue are we good to close this one after today's call?

I would love if someone could link to notes on how we will use reminders!

Yeah, we should document that. @awight do you have a suggestion for a place?

@RLewis @CaitVirtue can we close this following the call with Kellie last week?

@awight @ccodgill_wmf where would be a good place to write this down? Collab/DS pages about civi?

@Ejegg found https://collab.wikimedia.org/wiki/Fundraiser_2013/Donor_Services_Documentation which is really great stuff. Sort of too bad it's private, but I guess reminders would fit into this doc perfectly.

Let's put it with the rest of the DS Docs.

@RLewis @CaitVirtue are you all set on this one? Can you put the process in that collab page when you get a chance?

atgo renamed this task from Make Civi Reminders work to Make Civi Reminders work in Staging.Mar 9 2015, 9:14 PM

@Ejegg @RLewis @CaitVirtue I see a reminder went out - is this one closable now?

I think we can close this. Staging still isn't running anything automatically out of fear of spamming donors, but when I run the reminder job automatically it does the expected. We should be able to run automatic stuff in staging though, so I created T92904.

@atgo and @Ejegg sounds good. I wasn't sure if you had to figure something out with the automatic vs manual running of the reminder job but I can see you've created another task to cover this :-)

atgo claimed this task.