I was trying to set up a rule whereby when content is created ( Entity: [node], Field: field_client_com_name => A simple text field) the rule uses the field content to create a new taxonomy item.

Event: After saving new content

Condition: Entity has field => field_client_com_name ( a text field)

Actions: Create Entity => Taxonomy Term
Value => [node:field-client-com-name] (the value of the field_client_com_name text field)
Vocabulary => Here is the problem ??

On the Vocabulary filed the Data Selector (required), the options given seem unrelate: node:source:author, node:source:source, node:source:body:

Wouldn't this filed show the name of Vocabularies available to pick from? Or am I using this wrong at all?

Comments

fago’s picture

Title: Taxonomy Entity: Vocabulary Data Selector Wrong? » Add direct input support for entities
Component: Rules Core » Rules Engine
Category: support » task

Yep, we need to add support for directly selecting specific entities. For now, you can workaround it by using the "Fetch entity" action to fetch the vocabulary before using the entity create action.

3rdLOF’s picture

Thanks for that tip fago.

fago’s picture

Status: Active » Fixed

implemented that :)

Status: Fixed » Closed (fixed)

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

ace11’s picture

Can you be more spesific how the solution for this goes?

ace11’s picture

Status: Closed (fixed) » Active

Sorry for opening this but need urgent help!

3rdLOF’s picture

I exported the rules I made. You need THREE rules to complete all the possible actions: Create, Update and Delete.

You will need to change the names of the fields, content types and the vocabulary number to match yours before importing these rules as they are set for my particular set up.

Here you go buddy:

This will create a taxonomy value from the node title

{ "rules_project_taxonomy_from_node" : {
    "LABEL" : "Create Project Taxonomy from Node Title",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "rules" ],
    "ON" : [ "node_insert" ],
    "IF" : [
      { "node_is_of_type" : { "node" : [ "node" ], "type" : { "value" : { "project" : "project" } } } }
    ],
    "DO" : [
      { "entity_create" : {
          "USING" : {
            "type" : "taxonomy_term",
            "param_name" : [ "node:title" ],
            "param_vocabulary" : "8"
          },
          "PROVIDE" : { "entity_created" : { "entity_created" : "Created entity" } }
        }
      }
    ]
  }
}

This one will UPDATE a taxonomy WHEN a node title is updated.

{ "rules_update_proj_taxo_from_node_title" : {
    "LABEL" : "Update Project Taxonomy from Node Title",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "rules" ],
    "ON" : [ "node_presave" ],
    "IF" : [
      { "NOT entity_is_new" : { "entity" : [ "node" ] } },
      { "node_is_of_type" : { "node" : [ "node" ], "type" : { "value" : { "project" : "project" } } } }
    ],
    "DO" : [
      { "variable_add" : {
          "USING" : { "type" : "text", "value" : [ "node-unchanged:title" ] },
          "PROVIDE" : { "variable_added" : { "prior_term" : "Prior Term" } }
        }
      },
      { "entity_query" : {
          "USING" : {
            "type" : "taxonomy_term",
            "property" : "name",
            "value" : [ "prior-term" ]
          },
          "PROVIDE" : { "entity_fetched" : { "entity_fetched" : "Fetched entity" } }
        }
      },
      { "data_set" : { "data" : [ "entity-fetched:0:name" ], "value" : [ "node:title" ] } },
      { "entity_save" : { "data" : [ "entity-fetched:0" ], "immediate" : 1 } }
    ]
  }
}

This one will DELETE a taxonomy value when a node is deleted:

{ "rules_delete_proj_taxo_from_node_title" : {
    "LABEL" : "Delete Project Taxonomy from Node Title",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "rules" ],
    "ON" : [ "node_delete" ],
    "IF" : [
      { "node_is_of_type" : { "node" : [ "node" ], "type" : { "value" : { "project" : "project" } } } }
    ],
    "DO" : [
      { "entity_query" : {
          "USING" : {
            "type" : "taxonomy_term",
            "property" : "name",
            "value" : [ "node:title" ]
          },
          "PROVIDE" : { "entity_fetched" : { "entity_fetched" : "Fetched entity" } }
        }
      },
      { "entity_delete" : { "data" : [ "entity-fetched:0" ] } }
    ]
  }
}

Peace and good luck.

ace11’s picture

Ok, thanks! But is there any way to resolve vocabulary id without drush? How?

3rdLOF’s picture

Drush? There is no drush. Where do you get Drush from?

ace11’s picture

I just tried to google about getting/finding out vocabulary id and there was instructions how to do it in drush.
But I just mean how to find out vocabulary id?

3rdLOF’s picture

Just look at your database....the "taxonomy_vocabulary" table...look at it and you will see a list of all your vocabularies. The ID is the "vid" field.

3rdLOF’s picture

Or install Schema and use it to look at the database from inside the admin

fago’s picture

Status: Active » Fixed

Please do not re-open fixed issues unless it really isn't fixed. Better create a separate support issue and e.g. link it from here.

ace11’s picture

Status: Fixed » Active

Thanks kannary100! It really works :)

And yes, sorry for opening - wont do it again.

fago’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

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