Creating entities

Last updated on
30 November 2019

Drupal 7 will no longer be supported after January 5, 2025. Learn more and find resources for Drupal 7 sites

You can use this action to:
* create a user
* create a node
* ...

Creating Multiple Entities

To create multiple entities, use the 'Save entity' action after the 'Create a new entity' action.

Below is an example component rule which illustrates this. When executed, it asks for a list of titles from which to create a group of pages.

{ "rules_list_create" : {
    "LABEL" : "List create",
    "PLUGIN" : "rule",
    "REQUIRES" : [ "rules" ],
    "USES VARIABLES" : { "titles" : { "label" : "Titles", "type" : "list\u003Ctext\u003E" } },
    "DO" : [
      { "LOOP" : {
          "USING" : { "list" : [ "titles" ] },
          "ITEM" : { "list_item" : "Current list item" },
          "DO" : [
            { "entity_create" : {
                "USING" : {
                  "type" : "node",
                  "param_type" : "page",
                  "param_title" : [ "list-item" ],
                  "param_author" : [ "site:current-user" ]
                },
                "PROVIDE" : { "entity_created" : { "entity_created" : "Created entity" } }
              }
            },
            { "entity_save" : { "data" : [ "entity-created" ], "immediate" : 1 } }
          ]
        }
      }
    ]
  }
}

Help improve this page

Page status: No known problems

You can: