0

I have an action set as a scheduled task that deletes a user, that seems to be working fine:

{ "rules_delete_unregistered_user" : {
    "LABEL" : "Delete unregistered user",
    "PLUGIN" : "action set",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "USES VARIABLES" : { "user" : { "label" : "user", "type" : "user" } },
    "ACTION SET" : [ { "entity_delete" : { "data" : [ "user" ] } } ]
  }
}

and I also have a rule, that should delete this action set, but it fails:

{ "rules_user_accepted" : {
    "LABEL" : "user_accepted",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "rules_scheduler" ],
    "ON" : { "user_update" : [] },
    "IF" : [
      { "data_is" : { "data" : [ "account:field-accepted" ], "value" : "1" } }
    ],
    "DO" : [
      { "schedule_delete" : {
          "component" : "rules_delete_unregistered_user",
          "task" : [ "account:uid" ]
        }
      }
    ]
  }
}

now I do not have any idea what should I use as a task identifier to delete that action set.

EDIT:

the rule that schedules the action set:

{ "rules_create_new_user_after_registration_form" : {
    "LABEL" : "create_new_user_after_registration_form",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "TAGS" : [ "new user based on webform" ],
    "REQUIRES" : [ "webform_rules", "rules", "php", "rules_scheduler" ],
    "ON" : { "webform_rules_submit" : [] },
    "IF" : [
      { "webform_has_id" : {
          "form_id" : [ "form-id" ],
          "selected_webform" : { "value" : { "webform-client-form-104" : "webform-client-form-104" } }
        }
      }
    ],
    "DO" : [
      { "entity_create" : {
          "USING" : {
            "type" : "user",
            "param_field_lastname" : "[data:lastname1-value-raw]",
            "param_field_firstname" : "[data:firstname-value-raw]",
            "param_name" : "[data:email-value-raw]",
            "param_mail" : "[data:email-value-raw]"
          },
          "PROVIDE" : { "entity_created" : { "new_user_request" : "new_user_request" } }
        }
      },
      { "entity_query" : {
          "USING" : {
            "type" : "user",
            "property" : "uid",
            "value" : [ "new-user-request:uid" ]
          },
          "PROVIDE" : { "entity_fetched" : { "user_fetched" : "Fetched entity" } }
        }
      },
      { "schedule" : {
          "component" : "rules_delete_unregistered_user",
          "date" : { "select" : "site:current-date", "date_offset" : { "value" : 60 } },
          "param_user" : [ "user-fetched:0" ]
        }
      }
      }
    ]
  }
}

this actually works fine.

0

If you go to /admin/config/workflow/rules/schedule you will see a table of your scheduled components. One of the columns in that table is the task identifier - that's the string you will have to use to delete the scheduled task. You didn't post any details related to the scheduling, so I don't know what you used as a task identifier. The task identifier is necessary because one component may be queued to execute many many times, each time with a different identifier. The component name is not unique. The task identifier is.

  • I edited my question with the rule that schedules the action set. – buboreka Aug 9 at 9:18
0

Anonymus was right I did not provide identifier, so I had to update the rule, and now it is working:

{ "rules_create_new_user_after_registration_form" : {
    "LABEL" : "create_new_user_after_registration_form",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "TAGS" : [ "new user based on webform" ],
    "REQUIRES" : [ "webform_rules", "rules", "php", "rules_scheduler" ],
    "ON" : { "webform_rules_submit" : [] },
    "IF" : [
      { "webform_has_id" : {
          "form_id" : [ "form-id" ],
          "selected_webform" : { "value" : { "webform-client-form-104" : "webform-client-form-104" } }
        }
      }
    ],
    "DO" : [
      { "entity_create" : {
          "USING" : {
            "type" : "user",
            "param_field_lastname" : "[data:lastname1-value-raw]",
            "param_field_firstname" : "[data:firstname-value-raw]",
            "param_name" : "[data:email-value-raw]",
            "param_mail" : "[data:email-value-raw]"
          },
          "PROVIDE" : { "entity_created" : { "new_user_request" : "new_user_request" } }
        }
      },
      { "entity_query" : {
          "USING" : {
            "type" : "user",
            "property" : "uid",
            "value" : [ "new-user-request:uid" ]
          },
          "PROVIDE" : { "entity_fetched" : { "user_fetched" : "Fetched entity" } }
        }
      },
      { "schedule" : {
          "component" : "rules_delete_unregistered_user",
          "date" : { "select" : "site:current-date", "date_offset" : { "value" : 60 } },
          "identifier" : [ "new-user-request:uid" ],
          "param_user" : [ "user-fetched:0" ]
        }
      }
      }
    ]
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.