My answer to "Rule to store user's last post date and scheduled rule based 30 day reminder" contains an illustration about how to delete scheduled tasks, using the "schedule_delete
": the schedule_delete
that is part of this rule is to ensure that previously "scheduled" reminders will get removed when updating the data field (so that it only triggers 1 reminder, and with the most recent date).
Here is a copy of the Rules Action included in that answer (which refers to the Rules Component that is also included in that answer):
..
"DO" : [
{ "schedule_delete" : {
"component" : "rules_send_email_notification",
"task" : "[account:name]"
}
},
{ "data_set" : { "data" : [ "account:field-next-article" ], "value" : "+30 day" } },
{ "schedule" : {
"component" : "rules_send_email_notification",
"date" : {
"select" : "account:field-next-article",
"date_offset" : { "value" : 2592000 }
},
"identifier" : "[account:name]",
"param_user_to_notify" : [ "account" ]
}
}
]
...
What is crucial in the context of this question here, is that you have to ensure that you give enough thought to the value you'll use for the identifier
of the scheduled task.
In my sample the choice was that for each user, at any time, there can only be 1 scheduled task for each user. So using the account name as the key for that identifier is perfect ... to make it unique, and to know exactly which scheduled task should be deleted also.