Question

I want to use rules in order to populate Organic Groups field X value with the value of field Y. Keeping in mind these fields are Organic Group fields.

Field X is a 'long text & summary' field, while field Y is a normal 'text field'.

I'm trying to use Rules Actions to achieve this but no luck so far.

Any suggestions?

Was it helpful?

Solution

Here is a rule (in Rules export format) that should be close to what your question is about:

{ "rules_og_populate_fields" : {
    "LABEL" : "OG populate fields",
    "PLUGIN" : "reaction rule",
    "ACTIVE" : false,
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "og" ],
    "ON" : { "og_user_insert" : [] },
    "IF" : [
      { "entity_has_field" : { "entity" : [ "node" ], "field" : "field_x" } },
      { "entity_has_field" : { "entity" : [ "node" ], "field" : "field_y" } }
    ],
    "DO" : [
      { "data_set" : {
          "data" : [ "node:field-y" ],
          "value" : "[node:title-x]"
        }
      }
    ]
  }
}

You didn't specify which Rules Event you want to use. In my sample, I used "User has become a group member" (adapt the event to fit your own needs).

Notice the "entity has field" conditions, for both fields. Those conditions will make the fields available in the Rules Action ... (so that you can reference field X and set the value of field Y).

If you have the Rules UI enabled, and if the machine names of your fields are indeed "field_x" (for field X) and "field_y" (for field Y), you should be able to just import this rule in your own site. If you're using other machine names, just adapt the machine names prior to importing this rule (and apply similar changes in the fields mentioned in the Rules Action).

Licensed under: CC-BY-SA with attribution
Not affiliated with drupal.stackexchange
scroll top