Hello,

I want to have a rule that delete the Image content wich is referenced to the gallery. So I add a rule but this rule does not work. I attches the rule. Did someone see a mistake?

Thanks in advanced!

Frank

Here is the rule:

{ "rules_delete_a_gallery" : {
    "LABEL" : "Delete a gallery",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : { "node_delete" : [] },
    "IF" : [
      { "node_is_of_type" : {
          "node" : [ "node" ],
          "type" : { "value" : { "node_image_gallery" : "node_image_gallery" } }
        }
      }
    ],
    "DO" : [
      { "entity_query" : {
          "USING" : {
            "type" : "node",
            "property" : "node_gallery_ref_1",
            "value" : [ "node" ],
            "limit" : "100"
          },
          "PROVIDE" : { "entity_fetched" : { "entity_fetched" : "Fetched entity" } }
        }
      },
      { "LOOP" : {
          "USING" : { "list" : [ "entity-fetched" ] },
          "ITEM" : { "list_item" : "Current list item" },
          "DO" : [ { "entity_delete" : { "data" : [ "list-item" ] } } ]
        }
      },
      { "drupal_message" : { "message" : "Images [entity-fetched:0] which have been a reference to the deleted gallery were also deleted." } }
    ]
  }
}

Comments

fraweg’s picture

Component: Documentation » Miscellaneous
fraweg’s picture

... is this a stupid question? Did someone have working rules with this module?

Best regards
Frank

zengenuity’s picture

Status: Active » Fixed
{ "rules_delete_a_gallery" : {
    "LABEL" : "Delete a gallery",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : { "node_delete" : [] },
    "IF" : [
      { "node_is_of_type" : {
          "node" : [ "node" ],
          "type" : { "value" : { "node_gallery_gallery" : "node_gallery_gallery" } }
        }
      }
    ],
    "DO" : [
      { "entity_query" : {
          "USING" : {
            "type" : "node_gallery_relationship",
            "property" : "ngid",
            "value" : [ "node" ]
          },
          "PROVIDE" : { "entity_fetched" : { "entity_fetched" : "Fetched entity" } }
        }
      },
      { "LOOP" : {
          "USING" : { "list" : [ "entity-fetched" ] },
          "ITEM" : { "list_item" : "Current list item" },
          "DO" : [ { "entity_delete" : { "data" : [ "list-item:nid" ] } } ]
        }
      },
      { "drupal_message" : { "message" : "Images [entity-fetched:0] which have been a reference to the deleted gallery were also deleted." } }
    ]
  }
}
fraweg’s picture

Hello zengenuity,

you save my day! Thanks so much!

Best regards
Frank

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.