I have tried several times to get a rule working where it creates a new taxonomy term in the tags vocab after a certain event. Ideally I would use it to create a duplicate taxonomy term from another vocab once it's saved. I have successfully executed other actions (sending emails, displaying system messages) but I cannot get it to ever make a new taxonomy term. I can get this to work in the D7 version without issue. I have tried with both the data selection (little documentation so I could be configuring incorrectly) and direct input mode. My basic tests of entering "Some String" into vocab of "Tags" never works but my other rule that emails me and displays a system message works fine. Thoughts?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sbbutkcin created an issue. See original summary.

shabana.navas’s picture

Version: 8.x-3.0-alpha3 » 8.x-3.x-dev

I'm getting the same behaviour for all the 'Create a new @entity_type' actions. Looking into what the issue is.

shabana.navas’s picture

Status: Active » Needs review
FileSize
515 bytes

This one line seems to fix the issue and now the 'Create new @entity_type' actions work.

Status: Needs review » Needs work

The last submitted patch, 3: cannot_create_taxonomy-2900020-3.patch, failed testing. View results

sbbutkcin’s picture

I tested this patch out on a sandbox site and it causes the site to experience a 502 error every time I attempt to create a new term in any vocab list (the ones with the rule applied to it or not). On a freshly installed D8 site, it errors out with an exhausted memory error. What kind of environment were you able to successfully test this patch with?

TR’s picture

Category: Bug report » Support request
Status: Needs work » Fixed
Issue tags: -taxonomy, -tags

Here is a working Rule that creates a new Taxonomy term in the default "Tags" vocabulary when a new article node is created (the default article content type has a field_tags by default, so this Rule will work on any site, no special setup needed). The term name is the node title. This demonstrates that the "Create a new taxonomy term" action does work, and a patch is not needed. I think the key thing that you probably missed is that you have to save the term entity after you create it. That's true of all entities, and we don't want to change that because you should be able to create an entity that exists only for the scope of the rule. This is more of a UI/Documentation issue than a bug.

langcode: en
status: true
dependencies: {  }
id: check_taxonomy_term
label: 'Check Taxonomy Term'
events:
  -
    event_name: 'rules_entity_insert:node'
description: ''
tags:
  - ''
config_version: '3'
expression:
  id: rules_rule
  uuid: fb31400a-0f9b-443f-b2aa-4d0380b29fbe
  conditions:
    id: rules_and
    uuid: ad01eaed-d9c0-4316-b75b-199d38a93531
    conditions: {  }
  actions:
    id: rules_action_set
    uuid: 604f36fb-ac14-4261-ac45-9e35830adeb6
    actions:
      -
        id: rules_action
        uuid: cab094dc-d0fe-4b33-8e9f-7d2d3de50893
        context_values:
          vid: tags
          name: '{{ node.title.value }}'
        context_mapping: {  }
        context_processors:
          vid:
            rules_tokens: {  }
          name:
            rules_tokens: {  }
        provides_mapping: {  }
        action_id: 'rules_entity_create:taxonomy_term'
      -
        id: rules_action
        uuid: 059415ab-273c-4a72-93a4-96581a8cbbaf
        context_values:
          immediate: '1'
        context_mapping:
          entity: entity
        context_processors:
          immediate:
            rules_tokens: {  }
        provides_mapping: {  }
        action_id: rules_entity_save
      -
        id: rules_action
        uuid: 960c4bd7-1aba-4e8c-8263-51ccfd09c096
        context_values:
          message: 'Created taxonomy term {{node.title.value}}'
          type: warning
          repeat: false
        context_mapping: {  }
        context_processors:
          message:
            rules_tokens: {  }
          type:
            rules_tokens: {  }
          repeat:
            rules_tokens: {  }
        provides_mapping: {  }
        action_id: rules_system_message

Status: Fixed » Closed (fixed)

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